home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
ONLINE
/
TE2_134T
/
te2inst.003
/
ScrMenu.scr
< prev
next >
Wrap
Text File
|
1997-07-03
|
7KB
|
158 lines
/* --------------------------------------------------------------------- */
/* ScrMenu.scr - A TE/2 REXX Syntax Script */
/* Copyright 1994 by Oberon Software */
/* All rights reserved */
/* */
/* Notes: This sample script illustrates the use of: */
/* 1. Using Script file arguments in REXX */
/* 2. The TE/2 PopupMenu() function */
/* 3. The TE/2 ErrorMsg() function */
/* 4. Reading from a data file */
/* 5. Error handling in REXX Syntax TE/2 scripts */
/* */
/* Usage: ScrMenu MenuDefFile */
/* */
/* MenuDefFile Structure */
/* Line 1: This line will contain the Title Text for the menu */
/* Up to ten lines follow defining the menu items, they have the */
/* following format: */
/* /Menu Text/ScriptToRun/Arguments */
/* MenuText is simply the text you wish to appear on the menu */
/* ScriptToRun is the name of the script file to execute when that */
/* menu item is selected. */
/* Arguments may take one of several forms: */
/* Empty: Simply end the line after the last "/" to pass no */
/* arguments to the called script. */
/* HardCoded: Place the actual value of the arguments after the */
/* last "/". */
/* Prompted: If the Argument string is exactly "[ ]" (without */
/* the quotes, you will be prompted for the parameters. */
/* If you place anything inside the square brackets, it */
/* must be of the form "[Prompt Text%Default Value]". */
/* The default value text can be empty. */
/* */
/* Example: */
/* */
/* Sample Menu */
/* /Play WAV Files/PlayWAVs/ */
/* /Change Dir /ChDir/ */
/* /XonXoff Menu /XonXoff/ */
/* /XonXoff ON /XonXoff/TRUE */
/* /XonXoff OFF /XonXoff/FALSE */
/* /Set Paths /Paths/ */
/* /FaxWorks /FaxWorks/[Enter ON, OFF, or nothing for menu:%] */
/* */
/* --------------------------------------------------------------------- */
/* Variables used ------------------------------------------------------ */
ReturnCode = 0
MnuTitle = ''
MnuTop = 5
MnuLeft = 20
MnuAttr = 0x1f
MnuHiAttr = 0x71
MnuItem. = ''
MnuItem.0 = 0
MnuBuf = ''
MnuDelim = '/'
/* Check for arguments ------------------------------------------------- */
parse arg InFile
if length(InFile) = 0 then
do
'ErrorMsg("ScrMenu.Scr Parameter Error", "Usage: ScrMenu MenuDefFile")'
exit 1
end
if length(stream(InFile,'C','query exists')) = 0 then
do
'ErrorMsg("ScrMenu.Scr Parameter Error", "File:'InFile' does not exist.")'
exit 1
end
/* Load REXXUTIL Functions --------------------------------------------- */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/* Setup Error handling ------------------------------------------------ */
signal on error name errproc
/* Main Program -------------------------------------------------------- */
call ReadInfile
if ReturnCode = 0 then
do
i = ShowMenu()
if i > 0 & i <= MnuItem.0 then
ReturnCode = RunItemScript(i)
end
exit ReturnCode
/* Subroutines --------------------------------------------------------- */
ReadInfile:
call stream InFile, 'C', 'open read'
if stream(InFile, 'S') \= 'READY' then
do
ReturnCode = 1
return
end
MnuTitle = linein(InFile)
i = 1
do while i < 10
chLine = linein(InFile)
if stream(InFile, 'S') \= 'READY' then leave
if substr(chLine, 1, 1) \= '/' then leave
parse var chLine '/' MnuItem.i.Text '/' MnuItem.i.Script '/' MnuItem.i.Args
MnuItem.0 = i
i = i + 1
end
call stream InFile, 'C', 'close'
return
ShowMenu:
MnuBuf = ''
do i = 1 to MnuItem.0
MnuBuf = MnuBuf||MnuDelim||MnuItem.i.Text
end
MnuBuf = MnuBuf||MnuDelim
'PopupMenu("'MnuTitle'", "'MnuBuf'", 'mnuTop', 'mnuLeft', 'mnuAttr', 'mnuHiAttr', 1)'
return rc
RunItemScript:
parse arg i
if length(MnuItem.i.Args) > 0 & substr(MnuItem.i.Args,1,1) = '[' then
do
if MnuItem.i.Args = '[ ]' then
do
chPrompt = 'Enter parameter(s) for' MnuItem.i.Script
chDefault = ''
end
else
parse var MnuItem.i.Args '[' chPrompt '%' chDefault ']'
'sprintf("[%lu", OpenDialog(4, 4, 9, 76, DLogNormAttr))'
h = substr(rc,2)
'StrPut(5, 6, DLogNormAttr, "%s", "'chPrompt'")'
'StrGet("'chDefault'", 7, 6, 68, 255, DLogEdAttr, DLogEdHiAttr)'
MnuItem.i.Args = rc
'CloseDialog('h')'
/* Do you want empty string entries to abort the process? */
/* if length(MnuItem.i.Args) = 0 then return 0 */
end
'run("'MnuItem.i.Script'","'MnuItem.i.Args'")'
'itoa(rexxRC, 10)'
return rc
/* Error handler ------------------------------------------------------- */
errproc:
TE2rc = rc
say '!! Error in TE/2 call'
say 'rc =' TE2rc
say 'line number =' sigl
say 'instruction = ['sourceline(sigl)']'
exit 1