Try the following code
LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1
guicreatewindow()
guisetctlvalue()
guisetctlplacement(,,,,,,'NORMAL')
again:
DO FOREVER
guigetmsg()
IF EXISTS('GuiObject') == 0 THEN
DO
IF EXISTS('GuiSignal') THEN
DO
SELECT guisignal
WHEN 'STOP' THEN
LEAVE
WHEN 'OTHER_OPTION' THEN
NOP
OTHERWISE
NOP
END
END
END
CATCH SYNTAX
CONDITION('M')
SIGNAL again
CATCH HALT
FINALLY
guidestroywindow()
END
RETURN
wm_click_ok_button:
err = guigetctlvalue()
sw_stop = 0
nr_errors = 0
rc = check_file_contents(filename_entry)
RETURN
check_file_contents:
ARG filename_entry
guisetctlplacement('stop_button', , , , , 'ENABLE')
curr = 0
DO WHILE curr < 100000
curr = curr + 1
IF sw_stop = 1 THEN
RETURN 0
rc = check_contents(curr)
guigetmsg('CLEAR')
IF guisignal == "STOP" THEN
RETURN 0
END
rc = update_status_bar(' ', ' ')
RETURN 0
check_contents:
PARSE ARG curr
temp = 'Curr = 'curr
rc = insert_progress_list(temp)
IF curr = 10000 THEN
DO
oid_line = 'xxxx20081322'
SAY 'Setting invalid data'
END
ELSE
oid_line = 'xxxx20081122'
y = SUBSTR(oid_line,5,8)
DO
rc = DATE('O', y, 'S')
CATCH SYNTAX
nr_errors = nr_errors + 1
temp = 'Invalid date ('y') (line 'curr')'
rc = insert_progress_list(temp)
sw_error = 1
END
RETURN 0
wm_click_stop_button:
err = guiwake('STOP')
sw_stop = 1
temp = ' Analysis of file interrupted (line 'curr')'
rc = insert_progress_list(temp)
guisetctlplacement('stop_button', , , , , 'DISABLE')
RETURN
insert_progress_list:
PARSE ARG string
guisendmsg('results_list', 'ADDSTRING', , string)
guigetmsg('CLEAR')
IF nr_errors > 20 THEN
DO
temp = 'Too many errors - do you want to continue checking ?'
result = wdwsay.rex(temp, '?|YESNO')
IF result = 'NO' THEN
DO
err = "EPOX checking aborted"
RAISE HALT 1 DESCRIPTION (err)
END
ELSE
nr_errors = 1
END
RETURN 0
update_status_bar:
PARSE ARG part1, part2
status_bar = part1
guisetctlvalue('status_bar', 1 )
RETURN 0
Start it up and press the OK button. You'll notice that if you press the STOP button BEFORE you see the text 'Setting invalid data' in the console window, then the program stops as expected. If you DON'T press the button at all, you'll fail on the line with IF GuiSignal == "STOP" THEN with the error "Guisignal has no value". The error seems to be caused by
DO
rc = DATE('O', y, 'S')
CATCH SYNTAX
nr_errors = nr_errors + 1
temp = 'Invalid date ('y') (line 'curr')'
rc = insert_progress_list(temp)
sw_error = 1
END
. If the catch syntax kicks in, THEN you get the "Guisignal has no value" message. The work-around is obvious - test if guisignal exists, but this seems to be a bug nonetheless. (This "error" turned up since the program was copied from another existing one with the same code. However, that program had no test for a data with the do/end catch syntax code, so there, I don't need to test for guisignal existing) |