home *** CD-ROM | disk | FTP | other *** search
- /*
- * example.rexx
- * John Corigliano
- *
- * This script adds two (2) clock buttons to the taskbar. One button will
- * launch MultiView and the other starts a CLI. It is very simple and mostly
- * meant to be an example.
- * Note: there is no way to exit the script unless our buttons get removed
- * by StartMenu.
- */
-
- /* Give StartMenu some time to load */
- address command 'Wait 2 SECS'
-
- /* The list of programs */
- Programs.1.1 = "mview" /* ID */
- Programs.1.2 = "Sys:Utilities/MultiView" /* Program */
- Programs.1.3 = "Sys:Utilities/MultiView" /* Icon */
-
- Programs.2.1 = "cli"
- Programs.2.2 = "newcli"
- Programs.2.3 = "Sys:system/Shell"
-
- NumPrograms = 2
-
- OPTIONS RESULTS
-
- /* Need the support lib */
- if (~Show('L','rexxsupport.library')) then call AddLib('rexxsupport.library',0,-30,0)
-
- /* Make sure SMRexx is up */
- if (~Show('P', 'START_REXX')) then do
- say "SMRexx is not running!"
- exit
- end
-
- /* Create an AREXX port */
- if (~OpenPort(SM_LAUNCH_PORT)) then do
- say "Could not open port"
- exit
- end
-
- /* Send commands to SMRexx */
- num_gads = 0
- do x = 1 to NumPrograms
- /* Create a clock button */
- com = "SM_LAUNCH_PORT " || Programs.x.1 || " ICON=" || Programs.x.3
- ADDRESS START_REXX 'ADD_CLOCK' com
- if (0 == rc) then num_gads = num_gads + 1 /* Was it created ok? */
- end
-
- /* Hmmm, no gagets were created? */
- if (0 == num_gads) then do
- ClosePort(SM_LAUNCH_PORT)
- exit
- end
-
- /* Event loop */
- quitflag = 0
- do forever
- if (quitflag == 1) then leave
-
- /* Wait foe a message */
- t = WaitPkt(SM_LAUNCH_PORT)
-
- /* Get all messages */
- do forever
- p = GetPkt(SM_LAUNCH_PORT) /* Get message */
- if (0 == C2D(p)) then leave /* No more? */
-
- arg = getarg(p) /* Get string */
- t = Reply(p, 0) /* Reply to message */
-
- gad = SubWord(arg, 1, 1) /* Get gadget's id string */
- com = SubWord(arg, 2, 1) /* Get command */
-
- /* Find which gadget it is */
- do x = 1 to num_gads
- if (Upper(Programs.x.1) == gad) then do
- comline = Programs.x.2
- leave
- end
- end
-
- if ("HIT" == com) then address command 'run <>NIL:' comline /* Launch! */
- else do
- num_gads = num_gads - 1 /* Gadget has been */
- if (0 == num_gads) then quitflag = 1 /* removed! */
- end
- end
- end
-
- /* Delete our port */
- ClosePort(SM_LAUNCH_PORT)
-
- exit
-