Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Learning again how to code in REXX :(

Status
Not open for further replies.

Alph2000

Technical User
Jan 10, 2007
1
ES
Hello,

I've been programming REXX scripts under OS/2 for quite a while, and recently I decided it would be nice to have them handy to run under Windows as well, so I decided to try again...

Regina chokes on this sample because it complains about line #3 ('@Echo Off'), and after that (if I comment it out) seems to choke again in the line where I indirectly drop some variables, saying that I probably have an incomplete 'do' statement. It does so under OS/2 AND Windows. On Windows, Reginald chokes in the same places.

The code in question looks perfectly normal to me and runs perfectly in OS/2's classic REXX.

Could you please have a look at it and tell me if I have developed bad REXX coding habbits, and/or what's wrong anyway?

Many thanks,
Alfredo Fernández.




/* */

'@Echo Off'

if RxFuncQuery('SysLoadFuncs')>0 then do
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
end

parse source HostOS CallType ThisFile
select
when HostOS = 'OS/2' then
dir_sep = '\'
when HostOS = 'WIN32' then
dir_sep = '\'
otherwise
dir_sep = '/'
end

say HostOS dir_sep

attrlist.0 = 5
do i=1 to 5
attrlist.i = 'somename somevalue'
end

do x=1 to attrlist.0
if pos(' ',attrlist.x) > 0 then do
parse var attrlist.x attrname attrvalue
drop value(attrname)
call value attrname,attrvalue
end
else
attrname = attrlist.x
end

exit
 
The first line of your Rexx script should always start with /* REXX */ otherwise mainframes might get confused.

'@Echo Off' is a Windows Batch file command. I've never used OS/2, but I'm guessing it's not a valid command there. Maybe that should go in the
Code:
when HostOS = 'WIN32' then
section or removed completely?

Change
Code:
drop value(attrname)
to
Code:
say "value(attrname) returns:" value(attrname)
and see if it returns the name of an existing variable.
 
Regina chokes on this sample ... Reginald chokes in the same places.
Just thought I'd point out that ooRexx (on XP) doesn't choke on it at all.

But XP shows as 'WindowsNT', so the select statement needs refining . . .
Code:
select
 when pos('WIN',translate(hostos))<>0 then dir_sep='\'
 when hostos='os/2' then dir_sep='\'
 otherwise dir_sep='/'
end
ooRexx is Open Source, freely available from ooRexx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top