home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlbox13.zip / sample1.cmd < prev    next >
OS/2 REXX Batch file  |  1998-03-01  |  3KB  |  85 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.                     /* search the program and the menu file.          */
  14.                     /* The routine SearchProgramAndFiles sets the     */
  15.                     /* variables MENUFILE, MENUPROG and MENUPROGPATH. */
  16.   call SearchProgramAndFiles
  17.  
  18.   say 'Now calling ' 
  19.   say ' ' menuProg 
  20.   say 'with the menu file  ' 
  21.   say ' ' menuFile ' ... '
  22.  
  23.                     /* temporary change the PATH                      */
  24.                     /* (external REXX routines must be in a directory */
  25.                     /*  in the PATH!)                                 */
  26.   oldPath = value( 'PATH', , 'OS2ENVIRONMENT' )
  27.   call value 'PATH', menuProgPath || ';' || oldPath, 'OS2ENVIRONMENT'
  28.  
  29.                     /* init the variable for the dynamic menu         */
  30.   call value 'number', '0', 'OS2ENVIRONMENT' 
  31.   userInput = RXLBOX( menuFile )
  32.  
  33.                     /* restore the PATH                               */
  34.   call value 'PATH', oldPath, 'OS2ENVIRONMENT'
  35.  
  36.   say ''
  37.   say 'The result of RXLBOX is: "' || userInput || '"'
  38. exit
  39.  
  40. /* ------------------------------------------------------------------ */
  41. /* sub routine to search RxLBox.CMD & RxLBox.Men                      */
  42.  
  43. SearchProgramAndFiles:
  44.  
  45.                     /* search the program RXLBOX.CMD                  */
  46.   menuProg = directory() || menuProgName
  47.   if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then
  48.   do
  49.     parse source . . thisProgram
  50.     menuProg = fileSpec( 'D', thisProgram ) || ,
  51.                fileSpec( 'P', thisProgram ) || ,
  52.                menuProgName
  53.   end /* if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then */
  54.  
  55.   if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then
  56.   do 
  57.     say 'Error: ' || menuProgName || ' not found!'
  58.     exit 255
  59.   end  /* if stream( menuProg , 'c', 'QUERY EXIST' ) = '' then */
  60.   else
  61.     menuProgPath = fileSpec( 'D', menuProg ) || ,
  62.                    fileSpec( 'P', menuProg )
  63.  
  64.  
  65.                     /* search the menu file RXLBOX.INI                */
  66.   menuFile = directory() || menuFileName
  67.   if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then
  68.   do
  69.     parse source . . thisProgram
  70.     menuFile = fileSpec( 'D', thisProgram ) || ,
  71.                fileSpec( 'P', thisProgram ) || ,
  72.                menuFileName
  73.   end /* if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then */
  74.  
  75.   if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then
  76.   do 
  77.     say 'Error: ' || menuFileName || ' not found!'
  78.     exit 255
  79.   end  /* if stream( menuFile , 'c', 'QUERY EXIST' ) = '' then */
  80.  
  81. RETURN
  82.  
  83.  
  84. /* ------------------------------------------------------------------ */
  85.