Rexx Functions
+ ADDR(symbol)
+ returns the physical address of symbol contents.
+ (Normalized for MSDOS, ie seg:ofs = seg*16+ofs)
i = 5; say addr('i') /* something like 432009 decimal*/
say addr('j') /* -1, is J variable doesn't exist */
ADDRESS()
return the current environment for commands.
say address() /* would display: SYSTEM */
ARG([n[,option]])
ARG() - returns the number of arguments
ARG(n) - return then nth argument
ARG(n,option) - option may be Exist or Omitted
(only the first letter is significant) test
whether the nth argument Exists or is Omitted.
Returns "0" or "1"
call myproc 'a',,2
....
myproc:
say arg() /* 3 */
say arg(1) /* 'a' */
say arg(2,'O') /* 1 */
say arg(2,'E') /* 0 */
DATATYPE(string(,type))
DATATYPE(string) - returns "NUM" is string is a valid
REXX number, otherwise returns "CHAR".
DATATYPE(string,type) - returns "0" or "1" if string
is of the specific type:
- Alphanumeric: characters A-Z, a-z and 0-9
- Bits: characters '0' or '1'
- Lowercase: characters a-z
- Mixed: characters A-Z, a-z
- Number: is a valid REXX number
- Symbol: characters A-Z, a-z, 0-9, @%_.!#
- Uppercase: characters A-Z
- Whole-number: a valid REXX whole number
- X (heXadecimal):a valid HEX number
(only the first letter of type is required)
+ The special type 'Type' returns the either INT, REAL,
+ or STRING the way the variable is hold into memory
+ Usefull when you combine that with INTR function
say datatype('123') /* NUM */
say datatype('21a') /* CHAR */
say datatype(01001,'B') /* 1 */
+ say datatype(i,'T') /* maybe STRING */
DATE((option))
return current date in the format: dd Mmm yyyy
say date() /* 14 Feb 1993 */
or formats the output according to option
- Days returns number of days since 1-Jan as an integer
- European returns date in format dd/mm/yy
- Month returns the name of current month, ie. March
- Normal returns the date in the default format dd Mmm yyyy
- Ordered returns the date in the format yy/mm/dd (useful
for sorting)
- Sorted returns the date in the format yyyymmdd (suitable
for sorting)
- USA returns the date in the format mm/dd/yy
- Weekday returns the name of current day of week ie. Monday
DESBUF()
destroys the system stack, and returns the number of
lines in system stack.
push 'hello' /* now stack has one item */
call desbuf /* stack is empty, and RESULT=1 */
DIGITS()
returns the current setting of NUMERIC DIGITS.
Not used.
ERRORTEXT(n)
returns the error message for error number n.
say errortext(8) /* "Unexpected THEN or ELSE" */
FORM()
returns the current setting of NUMERIC FORM.
Not used.
FUZZ()
returns the current setting of NUMERIC FUZZ.
Not used.
GETENV(varname)
returns the environment variable "varname"
ie. say getenv("PATH")
+ INTR( num, reg-string )
+ executes a 80x86 soft-interrupt.
+ num = interrupt number, and reg-string is a string
+ in the format "ax=hex-num bx=hex-num ...."
+ returns in the same format the registers
regs = intr('10'h, 'ax=0003') /* will change video mode */
say regs /* AX=0003 BX=7B82 CX=.... FLAGS=C-PAS */
flags are returned as a string with characters
C - for carry, P-parity, A-Auxiliary carry, S-sign,
O - overflow, T-trap, I-interrupt ...
+ LOAD ( file )
+ load a rexx file so it can be used as a library.
+ load first searches the current directory and on
+ error it searches the directory defined by the
+ environment variable RXLIB.
+ (It would be nice to add in your AUTOEXEC.BAT the command
+ SET RXLIB=C:\PATH\WHERE\REXX\IS
+ SET TEMP=C:\TEMP
+ a temporary directory, maybe is allready set from Ms-Windows)
+ returns
+ "-1" when file is already loaded
+ "0" on success
+ "1" on error opening the file
MAKEBUF()
create a new system stack, and returns the number of
system stacks created until now (plus the initial one).
push 'hello'; say queued() /* display 1 */
call makebuf /* create a new buffer */
push 'aloha; say queued() /* display again 1 */
QUEUED()
return the number of lines in the rexx stack
push 'aha'
say queued() /* 1 */
push 'hello'
say queued() /* 2 */
call desbuf
say queued() /* 0 */
+ SOUNDEX(word)
+ return a 4 character soundex code of word
SOURCELINE([n])
return the number of lines in the program, or the nth
line.
say sourceline() /* maybe 100 */
say sourceline(1) /* maybe "/**/" */
STORAGE((address(,(length)(,data))))
| returns the current free memory size expressed as a
| decimal string if no arguments are specified.
| Otherwise, returns length bytes from the user's memory
| starting at address. The length is in decimal;
| the default is 1 byte. The address is a decimal number
| (Normalized address for MSDOS ie. seg:ofs = seg*16+ofs)
| If data is specified, after the "old" value has been
| retrieved, storage starting at address is overwritten
| with data (the length argument has no effect on this).
say storage() /* maybe 31287 */
say storage(1000,3) /* maybe "MZa" */
a = "Hello"
say storage(addr('a'),5,'aaa') /* "Hello" */
say a /* aaalo */
SYMBOL(name)
return "BAD" if name is not a valid REXX variable
name, "VAR" if name has been used as a variable, or
"LIT" if it has not.
i = 5
say symbol('i') /* VAR */
say symbol(i) /* LIT */
say symbol(':asd') /* BAD */
TIME((option))
return the local time in the format: hh:mm:ss
if option is specified time is formated as:
- Civil returns time in format hh:mmxx ie. 10:32am
- Elapsed returns elapsed time since rexx timer was reset
or from begging of program in format ssssss.uu
- Hours returns number of hours since midnight
- Long returns time and milliseconds hh:mm:ss.uu
- Minutes returns number of minutes since midnight
- Normal returns time in format hh:mm:ss
- Reset returns elapsed time in format ssssss.uu (like
Elapsed) and resets rexx internal timer.
- Seconds returns number of seconds since midnight
TRACE((option))
returns current tracing option. If option is specified
then sets to new tracing option. Look up instruction TRACE.
say trace() /* normally 'N' */
VALUE(name)
returns the value of the variable name.
i = 5; j = i
say value(j) /* 5 */
say value('j') /* 'i' */
+ VARTREE((symbol)(,option))
+ returns the binary tree of the variables in the format
+ var = "value"
+ if option is specified and the first letter is 'Depth'
+ then it prints out the binary tree in the format
+ depth var = "value" (used for balancing of variables )
+ symbol may be nothing for main bin-tree or a stem
+ for an array bin-tree ie. "B."
+ VARTREE is an easy way to store all or some variables
+ in a file or in stack and restores them later.
+ call write "vars.$$$", vartree() /* stores all variables */
+ exit /* in the file "vars.$$$" */
+ on a later run you can do
+ do until eof("vars.$$$") /* this will read all variables */
+ interpret read("vars.$$$") /* from file, and restore them */
+ end
+ WARNING! VARTREE is not fully implemented and may not work when
+ variables have non-printable characters.