Rexx Functions
ADDR(symbol[,[option][,pool]])
returns the physical address of symbol contents.
Option can be 'Data' (default) variables data
'Lstring' lstring structure pointer
'Variable' variable structure.
If pool exist, the specific rexx pool is searched
for the symbol. Valid pools are numbers from 0 up to
current procedure nesting.
(The result is normalized for MSDOS, ie seg:ofs = seg*16+ofs)
i = 5; |
|
SAY addr('i') | /* something like 432009 decimal */
|
SAY addr('i','L') | /* something like 433000 */
|
SAY addr('i','V') | /* something like 403004 */
|
SAY addr('i','V',0) | /* something like 403004 */
|
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
|
Binary: | a valid BINARY number
|
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 all system stacks, and returns the number of
lines in system stacks.
PUSH 'hello' | /* now stack has one item */
|
CALL desbuf | /* stack is empty, and RESULT=1 */
|
DROPBUF([num])
destroys num top stacks, and returns the number of
lines destroyed.
PUSH 'in stack1' | /* first stack has one item */
|
CALL makebuf | /* create a new buffer */
|
PUSH 'in stack2' | /* new stack has one item */
|
CALL dropbuf | /* one stack remains */
|
DIGITS()
returns the current setting of NUMERIC DIGITS.
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.
FUZZ()
returns the current setting of NUMERIC FUZZ.
GETENV(varname)
returns the environment variable varname
SAY getenv("PATH")
HASHVALUE(string)
return an integer hashvalue of the string like Java
hash = s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
SAY hashvalue("monday") | /* -1068502768 */
|
IMPORT( file )
import a shared library file using dynamic
linking with rexx routines.
If it fails, then try to load a rexx file so it can
be used as a library.
import first searches the current directory, if not found
it searches the directories pointed by the environment
variable RXLIB.
(It would be nice to add in your AUTOEXEC.BAT the command
SET RXLIB=C:\PATH\WHERE\REXX\IS
returns
"-1" if already imported
"0" on success
"1" on error opening the file
CALL import 'libmysql.so'
|
CALL import 'dates.r'
|
INTR( num, reg-string )
executes a 80x86 soft-interrupt. (ONLY IN MSDOS VERSION)
num = interrupt number, and reg-string is a string
in the format "ax=hex-num bx=hex-num ...."
with the register values.
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 - carry,
P - parity,
A - auxiliary carry,
S - sign,
O - overflow,
T - trap,
I - interrupt
LOAD( file )
Deprecated! Please use the IMPORT instead.
load a rexx file so it can be used as a library.
load first searches the current directory, if not found
it searches the directories pointed by the environment variable RXLIB.
(It would be nice to add in your AUTOEXEC.BAT the command
SET RXLIB=C:\PATH\WHERE\REXX\IS
returns
"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() queued(T) | /* display 1 1 */
|
CALL makebuf | /* create a new buffer */
|
PUSH 'aloha; SAY queued() queued(T) | /* display again 2 1 */
|
QUEUED([option])
return the number of lines in the rexx stack (all stacks or the
topmost) or the number of stacks.
Option can be (only first letter is significant):
All | lines in All stacks (default)
|
Buffers | number of buffers created with MAKEBUF
|
Topstack | lines in top most stack
|
PUSH 'hi' |
|
SAY queued(A) queued(B) queued(T) | /* 1 1 1 */
|
CALL makebuf |
|
SAY queued(A) queued(B) queued(T) | /* 1 2 0 */
|
PUSH 'hello' |
|
SAY queued(A) queued(B) queued(T) | /* 2 2 1 */
|
CALL desbuf |
|
SAY queued(A) queued(B) queued(T) | /* 0 1 0 */
|
SOUNDEX(word)
return a 4 character soundex code of word in the format "ANNN"
(used for phonetic comparison of words)
SAY soundex("monday") | /* M530 */
|
SAY soundex("Mandei") | /* M530 */
|
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 value 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.uuuuuu
|
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.uuuuuu (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[,[newvalue][,pool]])
returns the value of the variable name.
If newvalue is specified then after the retrieval
of the old value the newvalue will be set to the
variable.
If pool is specified then the operation takes place
at the specific pool. Pool initially exist in this version
of Rexx are:
- 0 up to the current PROCEDURE nesting
specifing the pool of each PROCEDURE
- Negative values from -1 to minus current PROCEDURE
nesting, shows relative values from current procedure.
- SYSTEM is the system pool (like GETENV,PUTENV)
- User can create his own POOLs,
Look Programing Rexx
i = 5; j = "i" |
|
SAY value(j) | /* 5 */
|
SAY value('j',10) | /* 'i' */
|
SAY j | /* 10 */
|
CALL Procedure |
|
... |
|
Procedure: PROCEDURE |
|
i = "I-var" |
|
SAY value('i') | /* I-var */
|
SAY value('i',,0) | /* 5 */
|
SAY value('i',,1) | /* I-var */
|
SAY value('i',,-1) | /* 5 */
|
...
|
VARDUMP([symbol][,option])
returns the binary tree of the variables in the format
var = "value" \n
option can be "Depth" which prints out the
binary tree in the format
depth var = "value" \n (used for balancing of variables )
symbol may be nothing for main bin-tree or a stem
for an array bin-tree ie. "B."
VARDUMP is an easy way to store the variables
in a file or in stack and restores them later.
CALL write "vars.$$$", vardump() /* stores all variables */
/* 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! VARDUMP is not fully implemented and may not work when
variables have non-printable characters.