home *** CD-ROM | disk | FTP | other *** search
- /* EnviMenu - Set environment variable from a menu created from a file
- * list. This is a simple use of RexxMenu to be called from
- * the OS/2 command line or from a simple command file.
- */
-
- if ARG(1) = "" then signal EnviMenuHelp
-
- /* Parse input into first the Environment Variable Name, and then each following
- * argument. If quotes then parse to end of quotes
- */
- PARSE ARG VariableName SourceArgs
- PARSE UPPER VAR VariableName VariableName
- if SourceArgs = "" then signal EnviMenuHelp
- RexxMenuStr = "RexxMenuResult = RexxMenu("
- do until SourceArgs = ""
- if LEFT(SourceArgs,1) = '"' then do
- SourceArgs = RIGHT(SourceArgs,LENGTH(SourceArgs)-1)
- PARSE VAR SourceArgs NextArg '"' SourceArgs
- end /* Do */
- else if LEFT(SourceArgs,1) = "'" then do
- SourceArgs = RIGHT(SourceArgs,LENGTH(SourceArgs)-1)
- PARSE VAR SourceArgs NextArg "'" SourceArgs
- end /* Do */
- else do
- PARSE VAR SourceArgs NextArg SourceArgs
- end /* Do */
- RexxMenuStr = INSERT(RexxMenuStr,"'")
- RexxMenuStr = INSERT(RexxMenuStr,NextArg)
- RexxMenuStr = INSERT(RexxMenuStr,"'")
- if \(SourceArgs = "") then
- RexxMenuStr = INSERT(RexxMenuStr,",")
- end /* do */
- RexxMenuStr = INSERT(RexxMenuStr,")")
-
- /* Execute RexxMenu with the REXX call parse in RexxMenuStr */
- if 1 = RxFuncQuery('RexxMenu') then
- CALL RxFuncAdd 'RexxMenu', 'RexxMenu', 'RexxMenu'
- interpret RexxMenuStr
-
- /* Save result of RexxMenu to the environment variable */
- interpret INSERT(INSERT(INSERT(INSERT("'SET ",VariableName),"="),RexxMenuResult),"'")
- signal AllDone
-
-
- EnviMenuHelp:
- if 1 = RxFuncQuery('RexxMenuHelp') then
- CALL RxFuncAdd 'RexxMenuHelp', 'RexxMenu', 'RexxMenuHelp'
- CALL RexxMenuHelp
- say
- say 'EnviMenu - A shell for calling RexxMenu from the command line or from a .cmd'
- say ' batch file. EnviMenu sets an environment variable from a menu.'
- say
- say 'SYNTAX: EnviMenu <ENVIRONMENT_VARIABLE> <FileSpec> [RexxMenu Options...]'
- say 'Where:'
- say ' ENVIRONMENT_VARIABLE - This environment variable will be set to the chosen'
- say ' menu option. Same as the <Choice> option in RexxMenu().'
- say ' FileSpec - Same as the <File> argument in RexxMenu().'
- say ' RexxMenu Options - Options can be added the same as they are in RexxMenu(),'
- say ' but there should not be commas between options, but spaces.'
- say
- say 'Example: To set environment variable CHOICE from the options "Yes",'
- say ' "No", and "Not Sure yet" listed in the file OPTIONS, enter the'
- say ' following at the command line or call from a batch file:'
- say ' EnviMenu CHOICE options /Prompt "Are you ready to rock?" /Init Yes'
- say
- signal AllDone
-
-
- AllDone:
-