/* GUIBEGIN WINDOW , 19, 147, 396, 188, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Convert Script Calls FONT 8, 400, MS Shell Dlg LIST 5, 17, 337, 67, BORDER|VSCROLL|TABSTOP, , Called, ALT "C" PUSH 351, 26, 40, 14, TABSTOP, , AddCalled, , Add PUSH 351, 47, 40, 14, TABSTOP, , RemoveCalled, , Remove TEXT 5, 5, 119, 8, GROUP, , , , Scripts that are called: TEXT 4, 87, 61, 8, GROUP, , , , Scripts to convert: LIST 4, 97, 337, 68, BORDER|VSCROLL|GROUP|TABSTOP, , Files, ALT "F" PUSH 350, 108, 40, 14, TABSTOP, , AddFile, , Add PUSH 350, 129, 40, 14, TABSTOP, , RemoveFile, , Remove PUSH 187, 171, 40, 14, TABSTOP, , Convert, , Convert DEND GUIEND */ /* This appends a .REX extension on all calls to external scripts. * * The external scripts that are called should be added to the "Scripts that are called" * listbox. The scripts to be altered should be added to the "Scripts to convert" * listbox. * * Limitations: * 1) It is assumed that you don't use a colon to put several CALL lines together like so: * CALL MyScript; CALL MyScript2 * Each CALL should be on its own line. * 2) There is a single space between the CALL keyword and the function name. * 3) You aren't using quotes around any function name like so: * CALL "MyScript" * "C:\MyScript"() */ OPTIONS "C_CALL LABELCHECK NOSOURCE" NUMERIC DIGITS 10 LIBRARY rexxgui GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() /* Did some handler for our main window call GuiWake()? Or perhaps it is * someone other than a window signaling us? */ IF EXISTS('GuiObject') == 0 THEN DO /* Perhaps one of our window event handlers below, or a control event * handler for some control in our main window, has called GuiWake() * to have us handle the event here. In that case, some signal should have * been passed to GuiWake() in order to let us know who signaled us and * why. The particulars of what signal your handlers choose to use is * totally open to your own design of your layout scripts and your main script. * * But if GuiObject is DROP'ed and GuiSignal is also DROP'ed, then this is * Reginald signaling us to do nothing here. */ IF EXISTS('GuiSignal') THEN DO /* One of our handlers below called GuiWake() to tell us to do something here. */ END END /* Some Child Window Layout script called GuiWake() to wake us up. GuiObject has * been set to the name of its object variable, and GuiSignal to whatever. */ ELSE DO /* If GuiSignal is DROP'ed, assume the child wants us to simply DROP its object. */ IF EXISTS('GuiSignal') == 0 THEN DROP (GuiObject) /* The child script wants something else. GuiSignal is telling us what. Do * a SELECT on GuiObject name to determine which window sent the signal. */ ELSE SELECT GuiObject /* Here you add a WHEN clause for each child object variable name. You * must uppercase the name. Then look at GuiSignal and do... whatever. */ WHEN 0 THEN NOP OTHERWISE END /* SELECT GuiObject */ END /* Some child script signaled us */ CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN WM_CLICK_AddCalled: DO /* Here are our file extensions that we filter. */ extensions = 'REXX Script (*.rex) | *.rex | All files (*.*) | *.*' /* Do the File Dialog */ GuiFile('FN', 'HIDEREADONLY|PATH|DIR', 'Pick out a called script', extensions) /* If he cancels or there is an error, we CATCH here. */ CATCH SYNTAX RETURN END /* Add the name to the "Called" listbox, minus path and extension. */ PATH("Pieces", FN) GuiSendMsg("Called", "ADDSTRING",, Pieces.2) RETURN WM_CLICK_AddFile: DO /* Here are our file extensions that we filter. */ extensions = 'REXX Script (*.rex) | *.rex | All files (*.*) | *.*' /* Do the File Dialog */ GuiFile('FN', 'HIDEREADONLY|PATH|DIR', 'Pick out a script to convert', extensions) /* If he cancels or there is an error, we CATCH here. */ CATCH SYNTAX RETURN END /* Add the name to the "Files" listbox. */ GuiSendMsg("Files", "ADDSTRING",, FN) RETURN WM_CLICK_RemoveCalled: GuiRemoveCtlText("Called", "") RETURN WM_CLICK_RemoveFile: GuiRemoveCtlText("Files", "") RETURN WM_CLICK_Convert: /* Get the script names that are called. */ GuiSendMsg("Called", "GETCOUNT") scriptNamesCount = GuiSignal DO i = 1 TO scriptNamesCount GuiSendMsg("Called", "GETLBTEXT", i, "scriptNames."||i) END /* Load, modify, and resave each script to be converted */ OPTIONS "CASELESS" GuiSendMsg("Files", "GETCOUNT") count = GuiSignal DO i = 1 TO count GuiSendMsg("Files", "GETLBTEXT", i, "FN") DO LOADTEXT("Lines.", FN) DO line = 1 TO Lines.0 DO i = 1 TO scriptNamesCount /* See if this line contains a CALL (scriptNames.i) */ offset = POS("CALL" scriptNames.i, lines.line) IF offset \== 0 THEN DO offset = offset + 5 lines.line = DELSTR(lines.line, offset, LENGTH(scriptNames.i)) lines.line = INSERT(scriptNames.i || ".rex", lines.line, offset) END lines.line = CHANGESTR(scriptNames.i || '(', lines.line, scriptNames.i || '.rex(') END /* called script names */ END /* Lines of the script */ /* Resave */ LoadText("Lines.", FN, 'S') CATCH NOTREADY CONDITION('M') RETURN END END RETURN