home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
rexx
/
rexxmenu
/
menupick.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-11-25
|
3KB
|
99 lines
/* MenuPick - Set environment variable from a menu created from the input.
* Expect input of type VAL:Description;VAL:Description;etc...
* and will set environment variable to VAL.
*/
if ARG(1) = "" then signal MenuPickHelp
/* Parse input into first the Environment Variable Name, uppercase
*/
PARSE ARG VariableName SourceArgs
PARSE UPPER VAR VariableName VariableName
if SourceArgs = "" then signal MenuPickHelp
/* Create MenuPickLst.0,1, etc for all the items selected
*/
ChoiceCount = 0
do until SourceArgs = ""
PARSE VAR SourceArgs MenuPickLst.ChoiceCount ";" SourceArgs
DescCount = ChoiceCount + 1
PARSE VAR MenuPickLst.ChoiceCount MenuPickLst.ChoiceCount ':' MenuPickLst.DescCount
if MenuPickLst.DescCount = "" then
MenuPickLst.DescCount = MenuPickLst.ChoiceCount
ChoiceCount = DescCount + 1
end /* do */
if ChoiceCount = 0 then signal MenuPickHelp
/* Create file of the display choices
*/
'@if exist MenuPLst.tmp del MenuPLst.tmp > NUL'
i = 0
do until i = ChoiceCount
i = i + 1
'@echo' MenuPickLst.i '>> MenuPLst.tmp'
i = i + 1
end /* do */
/* Create string to execute to call RexxMenum checking for TIMEOUT and PROMPT
*/
RexxMenuStr = "RexxMenuResult = RexxMenu('MenuPLst.tmp'"
if \(value('MP_TIMEOUT',,'OS2ENVIRONMENT') = "") then do
RexxMenuStr = INSERT(RexxMenuStr,",'/Time','")
RexxMenuStr = INSERT(RexxMenuStr,value('MP_TIMEOUT',,'OS2ENVIRONMENT'))
RexxMenuStr = INSERT(RexxMenuStr,"'")
end /* Do */
if \(value('MP_PROMPT',,'OS2ENVIRONMENT') = "") then do
RexxMenuStr = INSERT(RexxMenuStr,",'/Prompt','")
RexxMenuStr = INSERT(RexxMenuStr,value('MP_PROMPT',,'OS2ENVIRONMENT'))
RexxMenuStr = INSERT(RexxMenuStr,"'")
end /* Do */
RexxMenuStr = INSERT(RexxMenuStr,")")
/* Call RexxMenu, end it will set RexxMenuResult
*/
if 1 = RxFuncQuery('RexxMenu') then
CALL RxFuncAdd 'RexxMenu', 'RexxMenu', 'RexxMenu'
interpret RexxMenuStr
'@del MenuPLst.tmp > NUL'
if RexxMenuResult = "" then signal MenuPickHelp
/* Set environment variable based on RexxMenuResult
*/
i = 1
do while \(RexxMenuResult = MenuPickLst.i)
i = i + 2
end /* do */
i = i - 1
interpret INSERT(INSERT(INSERT(INSERT("'SET ",VariableName),"="),MenuPickLst.i),"'")
signal AllDone
MenuPickHelp:
say
say 'MenuPick - Set environment variable from a menu of options.'
say
say 'SYNTAX: MenuPick <ENVIRONMENT_VARIABLE> [Value[:Descr][;Value:Descr]...]'
say 'Where:'
say ' ENVIRONMENT_VARIABLE - This environment variable will be set to the chosen'
say ' menu Value.'
say ' Value - What the ENVIRONMENT_VARIABLE may be set to.'
say ' Descr - Paired with val, this is the choice that appears on the menu.'
say ' If no ":" delimiting description then Value will be shown.'
say
say 'The following environment variables are used if they have been set:'
say ' MP_TIMEOUT - Number of seconds to wait before timing out on the first choice.'
say ' MP_PROMPT - Text at top of screen to prompt for user selection.'
say
say 'Example: To set the screen lines, you may have a batch file as follows:'
say ' set MP_TIMEOUT=5'
say ' set MP_PROMPT=Choose screen height:'
say ' MenuPick LINES 25:Few big text lines;50:Many small text lines'
say ' mode 80,%LINES%'
say
signal AllDone
AllDone:
DROP MenuPickLst.