Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Bug in catch/guisignal ?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Bug in catch/guisignal ?
#12277
Posted by: Michael S 2008-01-29 17:31:37
Try the following code

/*

GUIBEGIN


WINDOW , 0, 1, 400, 274, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , EPOXchk
	FONT 8, 400, MS Shell Dlg
	MENU
	STATUS BOTTOM|GRIP, status_bar
	TEXT 8, 9, 38, 8, GROUP, , filename_text, , Filename
	ENTRY 49, 7, 308, 12, H_AUTO|BORDER|TABSTOP, CLIENTEDGE, filename_entry
	LIST 13, 33, 369, 187, NOTIFY|REALHEIGHT|BORDER|VSCROLL|HSCROLL|TABSTOP, , results_list
	PUSH 369, 6, 20, 14, TABSTOP, , filename_button, , ...
	GROUP 8, 24, 381, 202, , , results_group, , Results
	PUSH 284, 230, 31, 14, DEFAULT|TABSTOP, , ok_button, , Ok
	PUSH 321, 230, 31, 14, TABSTOP, , stop_button, , Stop
	PUSH 358, 230, 31, 14, TABSTOP, , cancel_button, , Cancel
DEND

MENU
	HEADING &Options
		ITEM &Print, print_details
		ITEM &Save, save_details
	<
	HEADING &Help
		ITEM Help &doc, help_location
		ITEM &Open help, help_open
	<
DEND
GUIEND

*/

LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1

guicreatewindow()
/* Now sync all the controls with their variables' values. */
guisetctlvalue()
guisetctlplacement(,,,,,,'NORMAL')

again:
DO FOREVER
	guigetmsg()
	IF EXISTS('GuiObject') == 0 THEN 		
		DO			
			IF EXISTS('GuiSignal') THEN
				DO
					/* One of our handlers below called GuiWake() to 
						 tell us to do something here. */
					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:

/* Get all the entries from the window */
err = guigetctlvalue() 

sw_stop = 0
nr_errors = 0
rc = check_file_contents(filename_entry)
	
RETURN
/*****************************************************************
 Let's check the contents of the file
*****************************************************************/ 
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					/* They pressed the STOP button - leave */ 
	rc = check_contents(curr)
	/* Did he click on the "Stop" button? If so, WM_CLICK_Stop
   called GuiWake, and GuiSignal was set to "STOP".  */
  guigetmsg('CLEAR')
  /* You need the test for if Guisignal exists below (MSCERAchk doesn't
     seem to. I THINK it's because the catch syntax when checking the
     data seems to require it
  */   
/*  if exists('GuiSignal') then
  	do */
			IF guisignal == "STOP" THEN 
				RETURN 0
/*		end		 */
END

/* Clear the status bar */
rc = update_status_bar(' ', ' ')

RETURN 0
/********************************************************** 
 Check the actual contents in the stem variable records. 
**********************************************************/
check_contents:

PARSE ARG curr

temp = 'Curr = 'curr
rc = insert_progress_list(temp) 

IF curr = 10000 THEN
	DO
		oid_line = 'xxxx20081322' /* Deliberate error */
		SAY 'Setting invalid data'
	END	
ELSE
	oid_line = 'xxxx20081122'	
	
y = SUBSTR(oid_line,5,8)   /* Check DAT-DOK-AVSER */
DO 
	rc = DATE('O', y, 'S')
	CATCH SYNTAX
		/* Error in the date */
		nr_errors = nr_errors + 1
		temp = 'Invalid date ('y') (line 'curr')'
		rc = insert_progress_list(temp) 
		sw_error = 1
END

RETURN 0
/************************************************************
 Stop the analysis
************************************************************/ 
wm_click_stop_button:
err = guiwake('STOP')
sw_stop = 1
/* Tell them stopped */
temp = '    Analysis of file interrupted (line 'curr')'
rc = insert_progress_list(temp)
guisetctlplacement('stop_button', , , , , 'DISABLE')
RETURN
/*********************************************************************
 Update the progress list to show what's happening
*********************************************************************/ 
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) /* RETURN (err) */				
			END	
		ELSE
			/* Reset the nr_errors counter. Note that we DELIBERATELY
			   set it to 1. If we set it to 0 and there were EXACTLY 
			   20 errors, then the code would think we had no problems
			   with the file. If we DIDN'T reset it, you'd start getting
			   a message after EVERY error after 20 of them */
			nr_errors = 1
	END

RETURN 0	
/****************************************************************************

****************************************************************************/
update_status_bar:
PARSE ARG part1, part2

status_bar = part1
/* ... update the status bar so we know how many records we've read so far ... */
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
		/* Error in the date */
		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)
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,800.00 ·
 
 
¥489.00 ·
 
 
¥288.00 ·
 
 
¥908.00 ·
 
 
¥748.00 ·
 
 
¥264.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0