home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXMENU2.ZIP / ENVIMENU.CMD < prev    next >
OS/2 REXX Batch file  |  1992-11-24  |  3KB  |  71 lines

  1. /* EnviMenu - Set environment variable from a menu created from a file
  2.  *            list.  This is a simple use of RexxMenu to be called from
  3.  *            the OS/2 command line or from a simple command file.
  4.  */
  5.  
  6. if ARG(1) = "" then signal EnviMenuHelp
  7.  
  8. /* Parse input into first the Environment Variable Name, and then each following
  9.  * argument.  If quotes then parse to end of quotes
  10.  */
  11. PARSE ARG VariableName SourceArgs
  12. PARSE UPPER VAR VariableName VariableName
  13. if SourceArgs = "" then signal EnviMenuHelp
  14. RexxMenuStr = "RexxMenuResult = RexxMenu("
  15. do until SourceArgs = ""
  16.    if LEFT(SourceArgs,1) = '"' then do
  17.       SourceArgs = RIGHT(SourceArgs,LENGTH(SourceArgs)-1)
  18.       PARSE VAR SourceArgs NextArg '"' SourceArgs
  19.    end  /* Do */
  20.    else if LEFT(SourceArgs,1) = "'" then do
  21.       SourceArgs = RIGHT(SourceArgs,LENGTH(SourceArgs)-1)
  22.       PARSE VAR SourceArgs NextArg "'" SourceArgs
  23.    end  /* Do */
  24.    else do
  25.       PARSE VAR SourceArgs NextArg SourceArgs
  26.    end  /* Do */
  27.    RexxMenuStr = INSERT(RexxMenuStr,"'")
  28.    RexxMenuStr = INSERT(RexxMenuStr,NextArg)
  29.    RexxMenuStr = INSERT(RexxMenuStr,"'")
  30.    if \(SourceArgs = "") then
  31.       RexxMenuStr = INSERT(RexxMenuStr,",")
  32. end /* do */
  33. RexxMenuStr = INSERT(RexxMenuStr,")")
  34.  
  35. /* Execute RexxMenu with the REXX call parse in RexxMenuStr */
  36. if 1 = RxFuncQuery('RexxMenu') then
  37.    CALL RxFuncAdd 'RexxMenu', 'RexxMenu', 'RexxMenu'
  38. interpret RexxMenuStr
  39.  
  40. /* Save result of RexxMenu to the environment variable */
  41. interpret INSERT(INSERT(INSERT(INSERT("'SET ",VariableName),"="),RexxMenuResult),"'")
  42. signal AllDone
  43.  
  44.  
  45. EnviMenuHelp:
  46. if 1 = RxFuncQuery('RexxMenuHelp') then
  47.    CALL RxFuncAdd 'RexxMenuHelp', 'RexxMenu', 'RexxMenuHelp'
  48. CALL RexxMenuHelp
  49. say
  50. say 'EnviMenu - A shell for calling RexxMenu from the command line or from a .cmd'
  51. say '           batch file.  EnviMenu sets an environment variable from a menu.'
  52. say
  53. say 'SYNTAX: EnviMenu <ENVIRONMENT_VARIABLE> <FileSpec> [RexxMenu Options...]'
  54. say 'Where:'
  55. say '  ENVIRONMENT_VARIABLE - This environment variable will be set to the chosen'
  56. say '           menu option.  Same as the <Choice> option in RexxMenu().'
  57. say '  FileSpec - Same as the <File> argument in RexxMenu().'
  58. say '  RexxMenu Options - Options can be added the same as they are in RexxMenu(),'
  59. say '           but there should not be commas between options, but spaces.'
  60. say
  61. say 'Example: To set environment variable CHOICE from the options "Yes",'
  62. say '         "No", and "Not Sure yet" listed in the file OPTIONS, enter the'
  63. say '         following at the command line or call from a batch file:'
  64. say '            EnviMenu CHOICE options /Prompt "Are you ready to rock?" /Init Yes'
  65. say
  66. signal AllDone
  67.  
  68.  
  69. AllDone:
  70.  
  71.