/*************************************************************************/ /* */ /* $VER: testgui.rexx 1.1 (Nov 27 1995) */ /* */ /* Script to test varexx GUI's */ /* */ /* Usage: rx testgui [GUINAME] */ /* */ /* Displays the given .GUI file and echos all messages to STDOUT */ /* */ /* Useful for testing .GUI files before the rest of the script is */ /* written. */ /* */ /*************************************************************************/ PARSE ARG gui_file IF ~SHOW('L','rexxsupport.library') THEN IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN EXIT IF ~SHOW('L','rexxreqtools.library') THEN IF ~ADDLIB('rexxreqtools.library',0,-30,0) THEN EXIT IF gui_file = '' THEN DO gui_file=rtfilerequest('REXX:gui',,'Varexx Request','_Load','rt_reqpos=reqpos_centerscr rtfi_matchpat=#?.gui rtfi_flags=freqf_patgad') IF gui_file = '' THEN EXIT END SAY 'Collecting window(s) from "'||gui_file||'".' windows. = '' windows.count = get_screens(gui_file) msg='These window(s) were found'||'0a'x||'in the .gui file...'||'0a'x||'0a'x gadgets='' DO cntr = 1 TO windows.count msg=msg||cntr||' - '||windows.cntr||'0a'x gadgets=gadgets||'_'||cntr||'|' END gadgets=gadgets||'_Quit' window = rtezrequest(msg,gadgets,'Varexx Request','rt_reqpos=reqpos_centerscr') IF (window = 0) THEN EXIT OPTIONS RESULTS OPTIONS FAILAT 20 SIGNAL ON SYNTAX SIGNAL ON FAILURE SIGNAL ON BREAK_C /* Check Varexx is loaded if not load it */ IF SHOW( 'p', 'VAREXX' ) ~= 1 THEN DO ADDRESS COMMAND 'run >NIL: varexx' ADDRESS COMMAND 'WaitForPort VAREXX' END ADDRESS 'VAREXX' IF OPENPORT('TEST_GUI') = 0 THEN DO SAY "Could not open a port." EXIT END 'load' gui_file 'TEST_GUI' vhost = result ADDRESS VALUE vhost 'show' UPPER(windows.window) /**************************************************************************/ /* MAIN LOOP -- Check for GUI events */ /**************************************************************************/ DO FOREVER CALL WAITPKT("TEST_GUI") packet = GETPKT("TEST_GUI") IF packet ~= '00000000'x THEN DO class = GETARG(packet) SAY class IF class = "CLOSEWINDOW" THEN LEAVE END END 'hide' 'unload' CALL CLOSEPORT('TEST_GUI') exit /* Error messages */ FAILURE: SYNTAX: SAY "Error code" rc "-- Line" SIGL SAY externerror BREAK_C: 'hide unload' CALL CLOSEPORT ('TEST_GUI') EXIT GET_SCREENS: procedure expose windows. PARSE ARG fname IF ~EXISTS(fname) THEN DO windows.1 = '' RETURN(1) END IF ~OPEN('gui',fname,'R') THEN DO windows.1 = '' RETURN(1) END win_count = 0 /* ** One of the worst piece of coding I have done for a while! :-( ** But it is the only way I know to find out all the window name(s) ** with out opening lots of libraries, and causing a bigger mess ** than it is now */ CALL READCH('gui',4) /* 'FORM' */ filesize = C2D(READCH('gui',4))+4 CALL READCH('gui',8) /* 8 char 'magic' name (one of many) */ jump = C2D(READCH('gui',4)) + SEEK('gui',0,'Current') /* Location of the next 'FORM' */ CALL SEEK('gui',jump+4,'Begin') /* Jump to location after the 'FORM' */ DO WHILE SEEK('gui',0,'Current') < filesize jump = C2D(READCH('gui',4)) + SEEK('gui',0,'Current') /* Location of the next 'FORM' */ IF READCH('gui',8) = 'GXWDWDDA' THEN /* The 'magic' name just before window names */ DO CALL READCH('gui',4) win_count = win_count + 1 byte=READCH('gui',1) DO WHILE byte ~= '00'x /* Get window name, $00 ends it */ windows.win_count = windows.win_count||byte byte=READCH('gui',1) END END CALL SEEK('gui',jump+4,'Begin') /* Jump to location after the 'FORM' */ END CLOSE('gui') RETURN(win_count)