home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rexxlb.zip
/
SAMPLES
/
TRYRXWIN.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-08-26
|
10KB
|
263 lines
/***************************************************************/
/* Try out RXWINDOW by calling a series of RXWINDOW functions. */
/***************************************************************/
outfile = 'tryrxwin.out'
call dosdel outfile
call lineout outfile,'work=w_open(5,5,20,70,112) /* 20x70 black on white window */'
call INIT
call INIT_FUNC
call HELP
call INIT_WIN
call MAIN
exit
INIT:
parse version . _n .
UnloadRXWINDOW = 0
if _n < 2.00 then do
say 'TRYRXWIN.REX requires REXX version 2.00 or later'
call BYE
end
call rxfuncadd 'w_register', 'rxwin30', 'rxwindow'
call w_register
return
INIT_FUNC:
func.1 = 'w_size window'
func.2 = 'w_unhide window'
func.3 = 'w_unfield window f_name'
func.4 = 'w_move window row col'
func.5 = 'w_attr window row col length attr'
func.6 = 'w_hide window [A|N]'
func.7 = 'w_scrput window row col string [T|A|B]'
func.8 = 'w_scrread window row col length [T|A|B]'
func.9 = 'w_field window f_name row col length [attr] [pad]'
func.10= 'w_read window [f_name] [activate:N|F]'
func.11= 'w_keys window [tab:J|N] [enter:A|L] [keyboard:F|E|O]'
func.12= 'w_scrwrite window row col [string] [length] [pad] [attr]'
func.13= 'w_put window row col [string] [length] [attr] [pad]'
func.14= 'w_get window row col length [string] [attr] [pad] [activate:N|F]'
func.15= 'w_border window [top] [right] [bot] [left] [attr]'
func.16= 'w_clear window [attr] [char] [row] [col] [height] [width]'
return
HELP:
parse value scrsize() with scr_height scr_width .
back = w_open(1,1,scr_height,scr_width,7) /* Background -- white on black window */
call w_hide back,'N'
help. = ''
help.1 = center('TRYRXWIN.REX',80)
help.3 = 'PURPOSE: Try out RXWINDOW functions.'
help.4 = ' All functions except W_OPEN and W_CLOSE can be tested.'
help.6 = 'TO USE: When TRYRXWIN is ready to accept an RXWINDOW function name, you will'
help.7 = ' see the prompt:'
help.9 = ' Enter a windowing function [ENTER to quit] w_'
help.11= ' Notice that the W_ that appears in the name of each windowing function'
help.12= ' is already given. Enter the rest of the name of the windowing function'
help.13= ' you want to run. For example, to try out the W_CLEAR function you type:'
help.15= ' CLEAR'
help.17= ' and then hit ENTER. (When you want to leave TRYRXWIN, don''t enter'
help.18= ' any text at this prompt--just hit ENTER.)'
help.19= ' You will then be prompted to enter each of the arguments for the'
help.20= ' function you''ve selected. Optional arguments appear in brackets.'
help.21= ' When all the arguments for the function have been entered,'
help.22= ' the value of the function is displayed on the screen, the effect of the'
help.23= ' function (if any) can be seen in the TRYRXWIN window, and the function'
help.24= ' call and its result are written to the file TRYRXWIN.OUT.'
help.25= right('Hit any key to continue...',80)
do i = 1 to 24
call w_scrwrite back,i,1,help.i,80
end
call w_scrwrite back,25,1,help.25,80
call w_unhide back
call inkey
drop help.
return
INIT_WIN:
call w_clear back
call w_hide back,'N'
do i = 6 to 23
call w_scrwrite back,i,5,'Text to see during W_HIDE or W_MOVE',70
end
call w_unhide back
work = w_open(5,5,20,70,112) /* Workspace -- black on white window */
return
MAIN:
signal on halt
signal on syntax
do forever
call GET_FUNC
call CALL_FUNC
end
return
GET_FUNC:
/* Select function to call */
msg = 'Enter a windowing function [ENTER to quit] w_'
call w_scrwrite back,2,2,msg,70
funcname = 'w_'w_get(back,2,length(msg)+2,8)
/* Exit if no function name is specified */
if substr(funcname,3) = '' then call BYE
else call GET_ARGS
return
GET_ARGS:
/* Construct argument list for function */
arg_string = 'work'
found = 0
do i = 1 to 16
if word(func.i,1) = funcname then do
found = 1
do k = 3 to words(func.i)
_argtype = word(func.i,k)
prompt = _argtype '=> '
call w_scrwrite back,2,2,prompt,70
_arg = check_arg(_argtype)
arg_string = arg_string"," || _arg
end
end
end
if \found then do
call w_clear back,,,3,2,1,70
call w_scrwrite back,2,2,'Function not found. Hit any key to continue...',70
call inkey /* Wait for user to hit a key */
call GET_FUNC /* Select function to call */
end
return
CHECK_ARG:
/* Be sure argument passed to function is valid */
arg _argtype
if pos('[',_argtype) then do
optional = 1
_argtype = strip(strip(_argtype,'T',']'),'L','[')
end
else optional = 0
do forever
_arg = w_get(back,2,length(prompt)+2,70)
select
when _arg='' then do
if \optional then do
call w_scrwrite back,2,2,'Argument must be specified. Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when _argtype='TOP' | _argtype='BOT' | _argtype='LEFT' | _argtype='RIGHT' then do
if \(datatype(_arg,'W') & (_arg > -1 & _arg < 3)) then do
call w_scrwrite back,2,2,'Argument must in range 0-2. Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when _argtype='ROW' | _argtype='COL' | _argtype='LENGTH' | _argtype='HEIGHT' | _argtype='WIDTH' then do
if \(datatype(_arg,'W') & _arg > 0) then do
call w_scrwrite back,2,2,'Argument must be nonzero whole number. Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when _argtype='ATTR' then do
if _arg < 0 | _arg > 255 then do
call w_scrwrite back,2,2,'Argument must be in the range 0-255. Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('T|A|B',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='T' | upper(_string)='A' | upper(_string)='B') then do
call w_scrwrite back,2,2,'Argument must be "T" or "A" or "B". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('A|N',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='A' | upper(_string)='N') then do
call w_scrwrite back,2,2,'Argument must be "A" or "N". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('TAB:',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='J' | upper(_string)='N') then do
call w_scrwrite back,2,2,'Argument must be "J" or "N". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('ENTER:',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='A' | upper(_string)='L') then do
call w_scrwrite back,2,2,'Argument must be "A" or "L". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('KEYBOARD:',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='F' | upper(_string)='E' | upper(_string)='O') then do
call w_scrwrite back,2,2,'Argument must be "F" or "E" or "O". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
when pos('ACTIVATE',_argtype) then do
_string = substr(strip(strip(_arg,,'"'),,"'"),1,1)
if \(upper(_string)='N' | upper(_string)='F') then do
call w_scrwrite back,2,2,'Argument must be "N" or "F". Hit any key to continue...',70
call PAUSE
end
else return _arg
end
otherwise return _arg
end
end
CALL_FUNC:
/* Call function, removing trailing commas from constructed argument list */
interpret 'value =' funcname'('strip(arg_string,'T',',')')'
/* Display results on screen and write results to output file */
call w_scrwrite back,3,2,'Result from' funcname 'is "'value'"',70
call lineout outfile,'call' funcname strip(arg_string,'T',',')
call lineout outfile,' /* Returns "'value'" */'
return
PAUSE:
/* Wait for the user to hit a key, then redisplay the prompt */
call w_clear back,,,3,2,1,70
call inkey
call w_scrwrite back,2,2,prompt,70
return
SYNTAX:
call w_scrwrite back,3,2,'REXX:' errortext(rc) '(error' rc'). Hit any key to continue...',70
call inkey
call w_clear back,,,3,2,1,70
call lineout outfile,'/* call' funcname strip(arg_string,'T',',')' */'
if pos('/*',errortext(rc)) \= 0 then call lineout outfile,' /* Unmatched quote or comment delimiter */'
else call lineout outfile,' /*' errortext(rc) '*/'
signal main
return
HALT:
call BYE
return
BYE:
call lineout outfile,'call w_close work'
call lineout outfile /* Close output file */
call w_close work /* Close Workspace window */
call w_close back /* Close Background window */
exit