home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma56.dms / ma56.adf / StartMenu / Extras / SMRexx / example.rexx < prev    next >
OS/2 REXX Batch file  |  1996-04-13  |  3KB  |  97 lines

  1. /*
  2.  * example.rexx
  3.  * John Corigliano
  4.  *
  5.  * This script adds two (2) clock buttons to the taskbar.  One button will
  6.  * launch MultiView and the other starts a CLI.  It is very simple and mostly
  7.  * meant to be an example.
  8.  * Note: there is no way to exit the script unless our buttons get removed
  9.  * by StartMenu.
  10.  */
  11.  
  12. /* Give StartMenu some time to load */
  13. address command 'Wait 2 SECS'
  14.  
  15. /* The list of programs */
  16. Programs.1.1 = "mview"                            /* ID */
  17. Programs.1.2 = "Sys:Utilities/MultiView"          /* Program */
  18. Programs.1.3 = "Sys:Utilities/MultiView"          /* Icon */
  19.  
  20. Programs.2.1 = "cli"
  21. Programs.2.2 = "newcli"
  22. Programs.2.3 = "Sys:system/Shell"
  23.  
  24. NumPrograms = 2
  25.  
  26. OPTIONS RESULTS
  27.  
  28. /* Need the support lib */
  29. if (~Show('L','rexxsupport.library')) then call AddLib('rexxsupport.library',0,-30,0)
  30.  
  31. /* Make sure SMRexx is up */
  32. if (~Show('P', 'START_REXX')) then do
  33.     say "SMRexx is not running!"
  34.     exit
  35.     end
  36.  
  37. /* Create an AREXX port */
  38. if (~OpenPort(SM_LAUNCH_PORT)) then do
  39.     say "Could not open port"
  40.     exit
  41.     end
  42.  
  43. /* Send commands to SMRexx */
  44. num_gads = 0
  45. do x = 1 to NumPrograms
  46.     /* Create a clock button */
  47.     com = "SM_LAUNCH_PORT " || Programs.x.1 || " ICON=" || Programs.x.3
  48.     ADDRESS START_REXX 'ADD_CLOCK' com
  49.     if (0 == rc) then num_gads = num_gads + 1  /* Was it created ok? */
  50.     end
  51.  
  52. /* Hmmm, no gagets were created? */
  53. if (0 == num_gads) then do
  54.     ClosePort(SM_LAUNCH_PORT)
  55.     exit
  56.     end
  57.  
  58. /* Event loop */
  59. quitflag = 0
  60. do forever
  61.     if (quitflag == 1) then leave
  62.  
  63.     /* Wait foe a message */
  64.     t = WaitPkt(SM_LAUNCH_PORT)
  65.  
  66.     /* Get all messages */
  67.     do forever
  68.         p = GetPkt(SM_LAUNCH_PORT)      /* Get message */
  69.         if (0 == C2D(p)) then leave     /* No more? */
  70.  
  71.         arg = getarg(p)                 /* Get string */
  72.         t = Reply(p, 0)                 /* Reply to message */
  73.  
  74.         gad = SubWord(arg, 1, 1)        /* Get gadget's id string */
  75.         com = SubWord(arg, 2, 1)        /* Get command */
  76.  
  77.         /* Find which gadget it is */
  78.         do x = 1 to num_gads
  79.             if (Upper(Programs.x.1) == gad) then do
  80.                 comline = Programs.x.2
  81.                 leave
  82.                 end
  83.             end
  84.  
  85.         if ("HIT" == com) then address command 'run <>NIL:' comline   /* Launch! */
  86.         else do
  87.             num_gads = num_gads - 1                      /* Gadget has been */
  88.             if (0 == num_gads) then quitflag = 1         /* removed!        */
  89.             end
  90.         end
  91.     end
  92.  
  93. /* Delete our port */
  94. ClosePort(SM_LAUNCH_PORT)
  95.  
  96. exit
  97.