home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdlg11.zip / rx.c < prev    next >
Text File  |  1995-03-03  |  2KB  |  75 lines

  1. /* RX.C (RX.EXE)
  2.  *
  3.  * This is a Presentation Manager program that launches a REXX script and allows it to open and use a PM window
  4.  * with PM controls in order to obtain user input (as opposed to "pull"ing from a command line prompt). It takes 1 arg
  5.  * from OS/2; the name of the REXX script to launch. It uses Rexx Dialog to implement the REXX/PM interface.
  6.  */
  7.  
  8. #define INCL_WINSYS
  9. #define INCL_WINWINDOWMGR
  10.  
  11. #include <os2.h>
  12. #include "rx.h"
  13.  
  14. HMQ hmq;
  15.  
  16. /********************************** main() ********************************
  17.  * 1. Initializes PM environment: obtains anchor block handle and creates msg queue
  18.  *    that all of the Rexx Dialog windows use.
  19.  * 2. Calls RexxSet() routine (init RXDLG.DLL stuff)
  20.  * 3. Executes REXX script
  21.  * 4. Frees resources
  22.  * 5. Ends program
  23.  *
  24.  * Return: 0 if successful execution, non-zero if error
  25.  *************************************************************************/
  26. int main(int argc, char *argv[], char *envp[])
  27. {
  28.     register ULONG id;
  29.  
  30.     /* Obtain a PM anchor block. Store it in REXXSPEC */
  31.     if(!(RexxSpec.Hab = WinInitialize(0)))
  32.     {
  33. badinit:
  34.     DosBeep(60, 120);
  35.     return(ERRAPP);
  36.     }
  37.  
  38.     /* Obtain a PM Message Queue */
  39.     if(!(hmq = WinCreateMsgQueue(RexxSpec.Hab, 0)))
  40.     {
  41.     WinTerminate(RexxSpec.Hab);
  42.     goto badinit;
  43.     }
  44.  
  45.     /* Is there a REXX script name specified? */
  46.     if (argc>1)
  47.     {
  48.     /* Install REXX support */
  49.     if((id = RexxSet()))
  50.     {
  51.         DlgErrMsg(id, id+ERRAPP);
  52.     }
  53.     else
  54.     {
  55.         /* Execute REXX script (if it exists) */
  56.         RexxRunScript(argv[1]);
  57.  
  58.         /* Uninstall REXX support */
  59.         RexxFree();
  60.     }
  61.     }
  62.     /* Print usage */
  63.     else
  64.     {
  65.     DlgMsgStr("Usage: RX [Rexx script filename]", 0, 0);
  66.     }
  67.  
  68.     /* Free resources */
  69.     WinDestroyMsgQueue(hmq);
  70.     WinTerminate(RexxSpec.Hab);
  71.  
  72.     /* Return error code */
  73.     return(RexxSpec.ErrNum);
  74. }
  75.