Michael
Michael

Reputation: 185

What is ! and : used for in REXX

What does the ! and : do in REXX. For instance in this piece of code

!all:!!=!;!=space(!);upper !;call !fid;!nt=right(!var('OS'),2)=='NT';!cls=word('CLS VMFCLEAR CLRSCREEN',1+!cms+!tso*2);if arg(1)\==1 then return 0;if wordpos(!,'? ?SAMPLES ?AUTHOR ?FLOW')==0 then return 0;!call=']$H';call '$H' !fn !;!call=;return 1
!cal:if symbol('!CALL')\=="VAR" then !call=;return !call
!env:!env='ENVIRONMENT';if !sys=='MSDOS'|!brexx|!r4|!roo then !env='SYSTEM';if !os2 then !env='OS2'!env;!ebcdic=1=='f0'x;return
!fid:parse upper source !sys !fun !fid . 1 . . !fn !ft !fm .;call !sys;if !dos then do;_=lastpos('\',!fn);!fm=left(!fn,_);!fn=substr(!fn,_+1);parse var !fn !fn '.' !ft;end;return word(0 !fn !ft !fm,1+('0'arg(1)))
!rex:parse upper version !ver !vernum !verdate .;!brexx='BY'==!vernum;!kexx='KEXX'==!ver;!pcrexx='REXX/PERSONAL'==!ver|'REXX/PC'==!ver;!r4='REXX-R4'==!ver;!regina='REXX-REGINA'==left(!ver,11);!roo='REXX-ROO'==!ver;call !env;return
!sys:!cms=!sys=='CMS';!os2=!sys=='OS2';!tso=!sys=='TSO'|!sys=='MVS';!vse=!sys=='VSE';!dos=pos('DOS',!sys)\==0|pos('WIN',!sys)\==0|!sys=='CMD';call !rex;return
!var:call !fid;if !kexx then return space(dosenv(arg(1)));return space(value(arg(1),,!env))

What is the !all:!!=! doing? I actually have a lot of questions looking at this piece of code but I figured we would start there and see if that sheds some light on the rest.

The original code sample is located here http://rosettacode.org/wiki/Terminal_control/Coloured_text#REXX

Upvotes: 2

Views: 337

Answers (1)

dsolimano
dsolimano

Reputation: 8986

As answered in the comments by Ryan Vincent:

The ! character is just another character you can use in 'variable names. So, instead of i in for loops you could use !. See the documentation and search for symbols.

The : is used at the end of a 'name' it indicate it is a 'label'. see: 12. Subroutines and functions. Trying to make sense of the 'optimized code that is shown will be 'interesting' but is possible. – Ryan Vincent Apr 18 at 19:55

Upvotes: 3

Related Questions