home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlbox13.zip / sample4.cmd < prev    next >
OS/2 REXX Batch file  |  1998-03-01  |  4KB  |  95 lines

  1. /* ------------------------------------------------------------------ */
  2. /*                                                                    */
  3. /*             sample program to show the use of RXLBOX               */
  4. /*                                                                    */
  5. /*            This program uses the menu file RXLBOX.MEN              */
  6. /*                                                                    */
  7. /* ------------------------------------------------------------------ */
  8.  
  9.                     /* init some constants                            */
  10.   menuProgName = 'RXLBOX.CMD' 
  11.   menuFileName = 'RXLBOX.MEN'
  12.  
  13.  
  14.                     /* search the program and the menu file.          */
  15.                     /* The routine SearchProgramAndFiles sets the     */
  16.                     /* variables MENUFILE, MENUPROG and MENUPROGPATH. */
  17.   call SearchProgramAndFiles
  18.  
  19.   say 'Now calling ' 
  20.   say ' ' menuProg 
  21.   say 'with the menu file  ' 
  22.   say ' ' menuFile 
  23.   say 'and some further parameter to set the initial menu stack ...'
  24.  
  25.                     /* temporary change the PATH                      */
  26.                     /* (external REXX routines must be in a directory */
  27.                     /*  in the PATH!)                                 */
  28.   oldPath = value( 'PATH', , 'OS2ENVIRONMENT'  )
  29.   call value 'PATH', menuProgPath || ';' || oldPath, 'OS2ENVIRONMENT'
  30.  
  31.                     /* init the variable for the dynamic menu         */
  32.   call value 'number', '0', 'OS2ENVIRONMENT'
  33.  
  34.                     /* set the parameter with the entries for the     */
  35.                     /* initial menu stack                             */
  36.  
  37.   InitialMenuStack = 'MainMenu,  Menu4,  Menu2,  REXXCmdMenu,' || ,
  38.                      'OS2CmdMenu,This is a hidden menu,' || ,
  39.                      'This is a [menu] with a long section name,' || ,
  40.                      'Menu7'
  41.  
  42.   userInput = RxLBox( menuFile, initialMenuStack )
  43.  
  44.  
  45.                     /* restore the PATH                               */
  46.   call value 'PATH', oldPath, 'OS2ENVIRONMENT'
  47.  
  48.   say ''
  49.   say 'The result of RXLBOX is: "' || userInput || '"'
  50. exit
  51.  
  52. /* ------------------------------------------------------------------ */
  53. /* sub routine to search RxLBox.CMD & RxLBox.Men                      */
  54.  
  55. SearchProgramAndFiles:
  56.  
  57.                     /* search the program RXLBOX.CMD                  */
  58.   menuProg = directory() || menuProgName
  59.   if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then
  60.   do
  61.     parse source . . thisProgram
  62.     menuProg = fileSpec( 'D', thisProgram ) || ,
  63.                fileSpec( 'P', thisProgram ) || ,
  64.                menuProgName
  65.   end /* if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then */
  66.  
  67.   if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then
  68.   do 
  69.     say 'Error: ' || menuProgName || ' not found!'
  70.     exit 255
  71.   end  /* if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then */
  72.   else
  73.     menuProgPath = fileSpec( 'D', menuProg ) || ,
  74.                    fileSpec( 'P', menuProg )
  75.  
  76.  
  77.                     /* search the menu file RXLBOX.INI                */
  78.   menuFile = directory() || menuFileName
  79.   if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then
  80.   do
  81.     parse source . . thisProgram
  82.     menuFile = fileSpec( 'D', thisProgram ) || ,
  83.                fileSpec( 'P', thisProgram ) || ,
  84.                menuFileName
  85.   end /* if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then */
  86.  
  87.   if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then
  88.   do 
  89.     say 'Error: ' || menuFileName || ' not found!'
  90.     exit 255
  91.   end  /* if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then */
  92.  
  93. RETURN
  94.  
  95.