|
home /
infca / rexx
(navigation links)
|
Rexx became reality on March 20th, 1979.
That day is considered Rexx's birthday.
|
Cosetes de Rexx
|
|
go 2 top
Definició i característiques
REXX is a procedural language that allows programs and algorithms to be written in a clear and structured way
- llenguatge sense definicions
- totes les variables son "string"
- pas de parametres per valor
code sample
See also *** data entry into a stem ***
sebas@minie:~/dades/rexx$ cat omple.rex
/* Rexx */ or #!/usr/bin/rexx
/* trace ?r */
/* omplir el disc D */
signal on Halt /* allow Ctrl-C end */
numBucles = 0 /* global loop counter */
szPfx = 'omple-'
szSufix = '.sag'
numFiles = 0 /* number of files in actual directory */
kFilesPerDir = 256
numDirs = 0
'D:' /* go to destination disk */
szNomDir = "DIR_" || numDirs
'mkdir ' szNomDir /* create first directory */
'cd ' szNomDir /* go to destination directory */
fOrigen = 'c:\sebas\rexx\font.tar' /* source file, must be BIG */
do forever
numBucles = numBucles + 1
fDesti = szPfx || numFiles || szSufix
say Time() "- bucle" numBucles "- dir" numDirs "- filename IN" fOrigen "- filename OUT" fDesti
'copy ' fOrigen fDesti /* fill the destination disk */
numFiles = numFiles + 1
if ( numFiles >= kFilesPerDir ) then
do
numFiles = 0
numDirs = numDirs + 1
szNomDir = "DIR_" || numDirs
'cd ..'
'mkdir ' szNomDir /* create new directory */
'cd ' szNomDir
end
end /* forever loop */
Halt : /* cerrar ordenadamente */
say "+++ Bye. Actual time is" Time()
return 0 /* always return a code */
Summary of expression syntax
Strings: "String constants" 'enclosed in quotes'
Hex strings: '616263 64'x
Numbers: 123.4e-56
Constant symbols: .abc 1d4 7!
Simple symbols: foo bar xyz3
Stems: array.
Compound symbols: c.3 element.bar.45
Operators: arithmetic: + - * / ** (to-power) % (div) // (mod)
string: [abuttal] [space] || (concatenation)
logical: \ (not) & (and) | (or) && (xor)
comparison: = > < <> <= >= \> \< \=
== >> << <<= >>= \>> \<< \== (strong comparison)
Function calls: fn(1,2,3) bar(,5) 'DATE'()
Summary of instructions
/* this is a comment */
expression - execute a host command
symbol=value - assignment
ADDRESS [VALUE] [environment] - change the current environment
ADDRESS environment command - execute a command in an environment
CALL name [arg][,[arg],...]] - call a function or subroutine
CALL ON condition [NAME symbol]- turn on condition handling
CALL OFF condition - turn off condition handling
condition = ERROR | FAILURE | NOTREADY | HALT
DO [ symbol=start [TO finish] ] [WHILE expression_w]
[ [BY step ] ]
[ [FOR count ] ] [UNTIL expression_u]
[ expression_c ] [FOREVER ]
- block or repetitive block instruction
DROP symbol [symbol...] - de-assignment
END [symbol] - end block or repetitive block instruction
EXIT [expression] - exit program or external function
IF expression [;] THEN [;] statement [ ; ELSE [;] statement]
- conditional instruction
INTERPRET expression - dynamically execute a string
ITERATE [symbol] - continue repetitive block
LEAVE [symbol] - leave repetitive block
NOP - do nothing
NUMERIC DIGITS n - set parameters for numeric formatting
NUMERIC FUZZ n
NUMERIC FORM SCIENTIFIC
| ENGINEERING
| "string constant"
| [VALUE] expression
OPTIONS expression - Control system-dependent things
[PARSE [UPPER]] ARG template
[PARSE [UPPER]] PULL [template]
PARSE [UPPER] LINEIN [template]
PARSE [UPPER] SOURCE template
PARSE [UPPER] VERSION template
PARSE [UPPER] NUMERIC template
PARSE [UPPER] VAR symbol template
PARSE [UPPER] VALUE expression WITH template
template -> [firstPosition] assignments [assignments]
assignments -> [nextPosition] varlist [stopPosition]
varlist -> varname ' ' [varlist]
varname -> "non-constant symbol"
| '.'
firstPosition -> position
nextPosition -> position [nextPosition]
stopPosition -> position
position -> searchPosition
| absPosition
| relPosition
| '(' "expression" ')'
searchPosition -> "string constant"
absPosition -> "integer"
| '=' numexpr
relPosition -> '+' numexpr
| '-' numexpr
numexpr -> "integer"
| '(' "integer expression" ')'
PROCEDURE - hide the caller's symbols
PROCEDURE EXPOSE var1 [var2...]
PROCEDURE HIDE var1 [var2...]
PUSH expression - stack a value in LIFO order
QUEUE expression - stack a value in FIFO order
RETURN [value] - return from a function or subroutine
SAY [expression] - echo data
SAYN expression - echo data without newline
SELECT [expression]
WHEN expression THEN statements
WHEN expression THEN statements
...
[OTHERWISE statements]
END [SELECT] - switch on a list of conditions
SIGNAL [VALUE] name - jump to a label
SIGNAL ON condition [NAME symbol] - turn on condition handling
SIGNAL OFF condition - turn off condition handling
condition = ERROR | FAILURE | NOTREADY | HALT | SYNTAX | NOVALUE
TRACE [symbol] - control program tracing. Values are:
TRACE "string" A (all clauses) C (commands) E (error)
TRACE VALUE expression F (failure) I (intermediate values)
L (labels) N (normal, =F) O (off)
R (results)
CALL details
The Rexx CALL instruction calls other Rexx programs :
call mysub1
To call a non-Rexx .CMD program named MYSUB2, write the CALL instruction like this:
"call mysub2"
The quotation marks around call mysub2 indicate that this is the Windows CALL command instead of a Rexx CALL instruction.
ooRexx tutorial
Summary of builtin functions
Standard functions
ABBREV(information,info[,length]) - check for valid abbreviations
ABS(number) - return the absolute value
ADDRESS() - return the current environment
ARG([n][,opt]) - return or test an argument
BITAND(string1,string2[,pad])
BITOR (string1,string2[,pad]) - combine two strings with bit operations
BITXOR(string1,string2[,pad])
B2D(binary)
B2X(binary)
D2B(decimal)
C2X(string)
C2D(string[,n])
D2C(decimal[,n]) - convert between data formats
D2X(decimal[,n])
X2B(hex)
X2C(hex)
X2D(hex)
CENTER(s,n[,pad]) - centre a string in a field
CENTRE(s,n[,pad])
COMPARE(s1,s2[,pad]) - compare two strings
CONDITION([option]) - return information about trapped condition
Option can be (default I):
C (condition name) D (description)
I (instruction) S (status)
COPIES(s,n) - replicate a string
DATATYPE(string[,type]) - test datatype. Type can be:
A (alphanumeric) B (bits) L (lowercase)
M (mixed case) N (number) S (symbol chars)
U (upper case) W (whole number) X (hex)
DATE([format]) - get date. Format can be:
B (base date - days since 1/1/1 AD)
C (days in century) D (days in year)
E (European) J (Julian) M (month name)
N (normal: dd Mon yyyy) O (ordered)
S (sorted) U (USA) W (day of week)
DELSTR(string,n[,length]) - delete substring
DELWORD(string,n[,length]) - delete words
DIGITS() - NUMERIC DIGITS setting
ERRORTEXT(i) - Rexx error message
FORM() - NUMERIC FORM setting
FORMAT(number [,[before] [,[after] [,[expp] [,expt]]]] )
- format a number as specified
FUZZ() - NUMERIC FUZZ setting
INSERT(new,target[,[n][,[length][,pad]]]) - insert new string into target
JUSTIFY(s,n[,pad]) - justify text to given width
LASTPOS(needle,haystack[,start]) - find last occurrence of a string
LEFT(string,num[,pad]) - return an initial substring
LENGTH(string) - find the length of a string
LINESIZE() - find the terminal width
MAX(number[,number...]) - find the maximum of a set
MIN(number[,number...]) - find the minimum of a set
OVERLAY(new,target[,[n][,[length][,pad]]]) - overlay new string on to target
POS(needle,haystack[,start]) - find the first occurance of a string
QUEUED() - return the number of items on the stack
RANDOM([min][,[max][,seed]]) - return a random number
REVERSE(string) - find the reverse of a string
RIGHT(string,num[,pad]) - return a final substring
SOURCELINE([i]) - return a line of the source program
SPACE(s[,[n][,pad]]) - evenly space words in a sentence
STRIP(string[,[opt][,char]]) - remove leading/trailing spaces
SUBSTR(string,n[,length[,pad]]) - return a substring
SUBWORD(string,n[,k]) - return a substring of words
SYMBOL(name) - test to see if a symbol is defined
TIME([format]) - get the time. Format can be:
C (civil time) N (normal) L (long)
H (hours since midnight)
M (minutes since midnight)
S (seconds since midnight) E (elapsed time)
R (elapsed time then reset)
TRACE([setting]) - get and/or set trace mode (see trace instruction)
TRANSLATE(string[,[tableo][,[tablei][,pad]]]) - translate characters using given tables
TRUNC(number[,n]) - truncate floating point number
VALUE(s[,[newvalue][,selector]]) - get or set value of a symbol
VERIFY(string,reference[,[option][,start]]) - verify string for valid characters
WORD(string,n) - return a word from a string
WORDINDEX(string,n) - return the position of a word in a string
WORDLENGTH(string,n) - return the length of a word in a string
WORDPOS(phrase,string[,start]) - find a phrase in a string
WORDS(string) - return the number of words in a string
XRANGE([a[,b]]) - return a range of characters
I/O functions (some of which are UNIX-specific)
CHARIN([stream] [,[position] [,count]]) - read characters
CHAROUT([stream] [,[string] [,position] ]- write characters
CHARS([stream]) - number of characters available
CLOSE(stream) - close a stream
FDOPEN(fd [,[mode] [,stream]]) - open an fd number
FILENO(stream) - find an fd number
FTELL(stream) - return the current file pointer
LINEIN([stream] [,[line] [,count]]) - read a line
LINEOUT([stream] [,[string] [,line]]) - write a line
LINES([stream]) - determine whether lines may be read
OPEN(file [,[mode] [,stream]]) - open a file
PCLOSE(stream) - close a pipe
POPEN(command [,[mode] [,stream]]) - open a pipe to a shell command
STREAM(stream [,[option] [,command]]) - miscellaneous stream operations
UNIX-specific functions
CHDIR(directory) - change to new directory
GETCWD() - return current working directory
GETENV(name) - get an environment variable
PUTENV(string) - set an environment variable
SYSTEM(s) - return the output of a shell command
USERID() - return the process owner's login name
Mathematical functions (implemented as separate package)
ACOS(x) the arc-cosine of x in radians (0<=acs(x)<=pi)
ASIN(x) the arc-sine of x in radians (-pi/2<=asn(x)<=pi/2)
ATAN(x) the arc-tangent of x in radians (-pi/2<=atn(x)<=pi/2)
COS(x) the cosine of x radians
EXP(x) the exponential of x (2.718281... to the power x)
LN(x) the natural logarithm of x (x>0)
SIN(x) the sine of x radians
SQRT(x) the square root of x (x>=0) [arbitrary precision possible]
TAN(x) the tangent of x radians (x <> pi/2)
TOPOWER(x,y) x to the power y
Built-in functions details
date([option])
returns the local date in various formats
date('E') == '27/08/89'
date('S') == '19890827' [ISO/R 2014-1971]
DATE argument must be one of BDEFLMNOSTUW
length(string)
returns the length of string
cnt = length( LineaEntrada )
linein([name][,[line][,count]])
returns count (0 or 1)
mind EOL can be 'windows' (CRLF, x0D0A, "\r\n") and 'unix' (LF only, x0A, "\n")
lineout([name][,[line]])
returns rc
iRC = lineout( StreamName, Line_Out ) ; // use without text (Line_Out) to close the input/output stream
overlay(new,target[,[n],[length][,pad]]])
overlays the string new onto the string target
LineaNova = overlay( " ", LiniaVella )
pos(needle,haystack[,start])
returns the position of one string , needle
in another, haystack
Inici = pos( "<A HREF=", LiniaFitxer )
right(string,length[,pad])
returns a string of length length
containing the right-most characters of string
Num2 = right( Num1, 4, '0' ) /* Num1 = 6 => Num2 = '0006' */
strip(string[,[option][,char]])
removes Leading, Trailing or Both leading and trailing
characters from string
Str2 = strip( Str1, 'L' ) /* Str1 = " ABC " => Str2 = "ABC " */
substr(string,n[,[length][,pad]])
returns a sub-string of string
that begins at the nth character
and is of length length.
Str2 = substr( Str1, 2, 4, '.' ) /* Str1 = "abc" => Str2 = "bc.." */
time([option])
returns the local time in various formats
time('') == '13:26:27'
time('S') == '48377'
TIME argument must be one of CEFHLMNORST (WXP says CEHLMNRS)
Open Object Rexx Version 4.1.3 => time() == "10:39:28"
From "The Rexx language. A practical approach to programming.",
by M.F. Cowlishaw,
section 9.
ISBN 0-13-780651-5, also ZB35-5100-01.
End Of Line
- CR, 0x0D - early Macintosh
- LF, 0x0A - UNIX based systems
- CR+LF, 0x0D 0x0A - Windows
If we download a page from Internet
(as view-source:https://www.rtve.es/alacarta/audios/el-sotano/),
it may come in "special" flavour,
so "windows" Rexx reads all data as one line - it has 0x0D as line separator.
ooRexx linein()
if (buffer[i] == '\n')
{
// once we hit a new line character, back up and see if the
// previous character is a carriage return. If it is, collapse
// it to the single line delimiter.
if (i >= 1 && buffer[i - 1] == '\r')
{
i--;
buffer[i] = '\n';
}
if EOL is 0x0D then
- use CHARIN() to read a byte at a time until it encounters the LF
- read all page in one line, and then :
- use WORDPOS() to find the position of the LF and SUBSTR to remove that record
- use PARSE() to split the data at the LF position
stackOverflow
Special Variables
When writing methods, you can use special variables available in REXX.
A special variable can be set automatically during the processing of a REXX program.
REXX supports the following variables:
- RC is set to the return code from any executed command, including those submitted with the ADDRESS instruction.
After the trapping of ERROR or FAILURE conditions, it is also set to the command return code.
When the SYNTAX condition is trapped, RC is set to the syntax error number (1-99).
RC is unchanged when any other condition is trapped.
Note: Tracing interactively does not change the value of RC.
- RESULT is set by a RETURN instruction in a subroutine that has been called,
or a method that was activated by a message instruction, if the RETURN instruction specifies an expression.
If the RETURN instruction has no expression on it, RESULT is dropped (becomes uninitialized).
RESULT is also set by an EXIT or REPLY instruction.
url
The RC special variable is where you get a process exit status from,
assuming you've run it as a host command (e.g. via ADDRESS, either explicitly or implicitly).
If you really are calling a function via CALL, the function's return value is in RESULT.
Expressions and Operators
Logical (Boolean)
A character string is taken to have the value "false" if it is '0',
and "true" if it is '1'.
& = And Returns 1 if both terms are true.
| = Inclusive Or Returns 1 if either term is true.
&& = Exclusive Or Returns 1 if either, but not both, is true.
\ = Logical Not Negates; 1 becomes 0 and vice versa.
From "The Rexx language. A practical approach to programming.",
by M.F. Cowlishaw,
section 3.
Test
What do you think the contents of B would in after the following instructions?
A = 45
B = A || 1 + 3
url
IF THEN ELSE instruction
The general form of this statement in Rexx is :
if (condition) then
do
#statement1
#statement2
end
else
do
#statement3
#statement4
end
Maybe more compact :
if (condition) then do
#statement1
#statement2
end
else do
#statement3
#statement4
end
A more complex condition :
if ( ( fIn \= '' ) & ( fIn \= '-') ) then FileIn = fIn
Keyword Instructions
PARSE [UPPER] { ARG / LINEIN / PULL / SOURCE / VALUE [expression] WITH / VAR
name / VERSION } [template]
used to assign data (from various sources) to one or more variables
according to the rules and templates described
PARSE ARG = string(s) passed to the program are parsed.
PARSE LINEIN = shorter form of PARSE VALUE LINEIN() WITH [template] ;
PARSE SOURCE = describes the source of the program being executed (how it was called)
PARSE VERSION = information describing the language level and the date of the language processor
PULL [template]
used to read a string from an external data queue.
It is a shorter form of the instruction
PARSE UPPER PULL [template] ;
Sample :
say "Do you want to erase the file ?"
pull answer .
if answer = 'YES' then Erase oldfile
From "The Rexx language. A practical approach to programming.",
by M.F. Cowlishaw,
section 7.
Debug
Error traps
On important conditions we use SIGNAL :
signal on failure name ExitProc
signal on halt name ExitProc
signal on syntax name ExitProc
How to start Rexx trace
Complete Rexx trace sentence (see rexxRex.pdf):
<>>-TRACE--+-+--------+-----------------------+--;--------------><
| +-number-+ |
| +-Normal--------+ |
+-+-----------+--+---------------+-+
| +-------+ | +-All-----------+
| V | | +-Commands------+
+-----?---+---+ +-Error---------+
+-Failure-------+
+-Intermediates-+
+-Labels--------+
+-Off-----------+
+-Results-------+
Interactive trace
The prefix ? controls interactive debugging. You will see a line like
+++ Interactive trace. "Trace Off" to end debug, ENTER to Continue. +++
How to stop the interactive trace
Enter "trace O" in the debug session (not in the Rexx code !)
url
Error trace
Traces any command resulting in an error or failure after execution, together with the return code from the command
/* trace ?r */
trace ?Errors
say "Return Code is =" RC
Samples
- If you want the interpreter to stop only when passing a label, use "trace ?l"
This is useful for setting breakpoints in the program
- if you want to trace inside an "IF", place a "trace r" at its input and enter "trace o" to continue
Flow control in Rexx ...
CASE in Rexx ... is SELECT
select
when ( Q == 1 ) then do
end /* Q = 1 */
when ( Q == 2 ) then do
end /* Q = 2 */
otherwise do
say "Dont know what to do ... Q =" Q
leave ;
end ;
end /* select */
Implementació WHILE, REPEAT, etc
do forever
...
if ... then leave /* exit condition */
...
end /* forever loop */
Special chars
CRLF string :
CRLF = D2C(13) || D2C(10) or CRLF = "0D0A0D0A"x
msg.msg = msg.msg || CRLF
TAB char :
tab = '09'x /* en hexadecimal */
SAY key || tab || value
Coloring output
#!/usr/bin/rexx
/*.----------------------------------------------------------------------.*/
/*|bashcolours: Display a table showing all of the possible colours that |*/
/*| can be generated using ANSI escapes in bash in an xterm |*/
/*| terminal session. |*/
/*| |*/
/*|Usage: |*/
/*| |*/
/*|>>-bashcolours-.----------.-----------------------------------------><|*/
/*| |-- -? ----| |*/
/*| |-- -h ----| |*/
/*| '- --help -' |*/
/*| |*/
/*|where |*/
/*| -?, -h or --help |*/
/*| display this documentation. |*/
/*| |*/
/*|This program is based on the shell script in the Bash Prompt HowTo at |*/
/*|http://www.tldp.org/, by Giles Orr. |*/
/*| |*/
/*|This program writes the various colour codes to the terminal to |*/
/*|demonstrate what's available. Each line showshe colour code of one |*/
/*|forground colour, out of 17 (default + 16 escapes), followed by a test|*/
/*|use of that colour on all nine background colours (default + 8 |*/
/*|escapes). Additional highlighting escapes are also demonstrated. |*/
/*| |*/
/*|This program uses object-oriented features of Open Object Rexx. |*/
/*|The lineout method is used instead of say for consistency with use of |*/
/*|the charout method. |*/
/*'----------------------------------------------------------------------'*/
call usage arg(1)
trace normal
/* See if escapes work on the kind of terminal in use. */
if value('TERM',,'ENVIRONMENT') = 'LINUX' then
do
say 'The Linux console does not support ANSI escape sequences for',
'changing text colours or highlighting.'
exit 4
end
/* Set up the escape sequences. */
! = '1B'x -- ASCII escape
bg = .array~of('[40m','[41m','[42m','[43m','[44m','[45m','[46m','[47m')
fg = .array~of('[0m', '[1m', '[0;30m','[1;30m','[0;31m','[1;31m',,
'[0;32m','[1;32m','[0;33m','[1;33m','[0;34m','[1;34m',,
'[0;35m','[1;35m','[0;36m','[1;36m','[0;37m','[1;37m')
hi = .array~of('[4m','[5m','[7m','[8m')
text = 'gYw' -- The test text
.OUTPUT~lineout(' ')
.OUTPUT~lineout('Foreground | Background Codes')
.OUTPUT~lineout(!'[4mCodes '!'[0m|'||,
!'[4m~[40m ~[41m ~[42m ~[43m ~[44m ~[45m ~[46m ~[47m'!'[0m')
do f = 1 to fg~size -- write the foreground info.
prefix = '~'fg[f]~left(6)' '!||fg[f]~strip' 'text
.OUTPUT~charout(prefix)
do b = 1 to bg~size -- write the background info.
segment = !||fg[f]~strip !||bg[b]' 'text' '!||fg[1]
.OUTPUT~charout(segment)
end
.OUTPUT~lineout(' ')
end
/* Write the various highlighting escape sequences. */
prefix = '~[4m'~left(6)' '!||hi[1]'Underlined'!||fg[1]
.OUTPUT~lineout(prefix)
prefix = '~[5m'~left(6)' '!||hi[2]'Blinking'!||fg[1]
.OUTPUT~lineout(prefix)
prefix = '~[7m'~left(6)' '!||hi[3]'Inverted'!||fg[1]
.OUTPUT~lineout(prefix)
prefix = '~[8m'~left(6)' '!||hi[4]'Concealed'!||fg[1],
"(Doesn't seem to work in my xterm; might in Windows?)"
.OUTPUT~lineout(prefix)
.OUTPUT~lineout(' ')
.OUTPUT~lineout("Where ~ denotes the ASCII escape character ('1B'x).")
.OUTPUT~lineout(' ')
exit
/*.--------------------------------------------------------.*/
/*|One might expect to be able to use directory collections|*/
/*|as below instead of array collections, but there is no |*/
/*|way to guarantee that a directory's indices will be |*/
/*|iterated over in a consistent sequence, since directory |*/
/*|objects are not ordered. Oh, well... |*/
/*'--------------------------------------------------------'*/
fg = .directory~new
fg[Default] = '[0m'; fg[DefaultBold] = '[1m'
fg[Black] = '[0;30m'; fg[DarkGray] = '[1;30m'
fg[Blue] = '[0;34m'; fg[LightBlue] = '[1;34m'
fg[Green] = '[0;32m'; fg[LightGreen] = '[1;32m'
fg[Cyan] = '[0;36m'; fg[LightCyan] = '[1;36m'
fg[Red] = '[0;31m'; fg[LightRed] = '[1;31m'
fg[Purple] = '[0;35m'; fg[LightPurple] = '[1;35m'
fg[Brown] = '[0;33m'; fg[Yellow] = '[1;33m'
fg[LightGray] = '[0;37m'; fg[White] = '[1;37m'
bg = .directory~new; hi = .directory~new
bg[Black] = '[0;40m'; hi[Underlined] = '[4m'
bg[Blue] = '[0;44m'; hi[Blinking] = '[5m'
bg[Green] = '[0;42m'; hi[Inverted] = '[7m'
bg[Cyan] = '[0;46m'; hi[Concealed] = '[8m'
bg[Red] = '[0;41m'
bg[Purple] = '[0;45m'
bg[Brown] = '[0;43m'
bg[LightGray] = '[0;47m'
usage: procedure
trace normal
if arg(1) = '-h',
| arg(1) = '-?',
| arg(1) = '--help'
then
do
line = '/*|'
say
do l = 3 by 1 while line~left(3) = '/*|'
line = sourceline(l)
parse var line . '/*|' text '|*/' .
.OUTPUT~lineout(text)
end
say
exit 0
end
return
url
Launching Rexx under Linux
You'd better have this very first line : "#!/usr/bin/rexx",
after "chmod 744 nom.rex"
Rexx input parameters
PARSE assigns data (from various sources) to one or more variables according to the rules of parsing
>>-PARSE--+-------+--+-ARG-----------------------+-------------->
'-UPPER-' +-EXTERNAL------------------+
+-NUMERIC-------------------+
+-PULL----------------------+
+-SOURCE--------------------+
+-VALUE-+------------+-WITH-+
| '-expression-' |
+-VAR--name-----------------+
'-VERSION-------------------'
>--+---------------+--;----------------------------------------><
'-template_list-'
Function arguments
Sample :
parse UPPER arg fIn fOut fTz Resto
fileIn = fileInDefault ;
if ( fIn \== '' ) then fileIn = fIn ;
How to parse a string
To parse a string, use
parse var input_line prefix "token" target "separator" sufix
parse source
The result of
#!/usr/bin/rexx
parse source my_host
say "Source is" my_host
return 0
... is {ooRexx under Ubuntu 18}
Source is LINUX COMMAND /home/nicolau/sebas/rexx/how/test.rex
Funcions interessants
- parse source HowWasCalled
- parse version VersionRexx
Also rexx -v
Rexx I/O functions
An excelent and complete
reference
If we dont want "lineout()" to do an "Append", we can code ...
iRC = stream( myFile, "c", "open" ) ; /* Explicitly opening a file */
record = linein( myFile, start, count ) ;
count = lineout( myFile, text, start ) ;
iRC = stream( myFile, "c", "close" ) ;
Rexx Inside and Out - File I/O
stream details
The syntax diagram is :
>>--- STREAM ---(--+-------------------------------------------------------------------------------------+--)------><
| |
+--- name ---+----------------------------------------------------------+-------------+
| |
+--- "," --- operation ---+--------------------------+-----+
| |
+--- "," --- command ------+
Function - Returns the state of the stream or the result of the command.
Parameters
- name - the stream name for the operation. This argument is case-sensitive.
- operation - the operation that is to be performed. Only the first character is significant.
- S
Returns the current state of the stream. This is the default operation. The following values can be returned:
- ready
The stream is available for normal input or output operations.
- error
The stream encountered an error on an input or output operation.
After this call, the error condition is reset, and normal input or output operations can be attempted once again.
- unknown
The specified stream is not open.
- D
This operation is almost the same as S, with one exception.
When error is returned, it is followed by text describing the error.
This text usually contains the error number and reason code if the failure is due to a system call failure.
- C
Executes a command for the specified stream. The command is specified as the third argument.
- command - the stream command that is to be executed.
This argument is valid only when the operation is C.
- clearfile : call stream name,'c','clearfile' - should only be used on a persistent stream
- close : call stream file,'c','close' - closes the stream or returns UNKNOWN
- infileno : fd=stream(name,'c','infileno') - returns the file descriptor of the input side of a stream.
- nosignal : call stream ,'c','nosignal' - disables Halt Interruption for stream errors
- open <open-type> : opens a stream. "open-type" specifies either read or write. The additional arguments are:
Examples :
- file=stream('mydata.txt','c','open write')
- file=stream('mydata.txt','c','open write replace') ;
- outfileno : fd=stream(name,'c','outfileno') - returns the file descriptor of the output side of a stream.
IBM knowledge center
Basic file data entry
Ejemple interessant : llegir tot un fitxer i mostrar la linia 9.
/* Rexx */
/* trace ?r */
signal on Halt /* allow Ctrl-C end */
say "+++ Hi. Actual time is" Time()
FIN = "FILE2.TXT" /* set input file name */
NLI = 0 /* init line count */
do while ( lines( FIN ) ) /* verify there is data */
LIN = linein( FIN ) /* get one line from file */
NLI = NLI + 1
if ( NLI == 9 ) then do
echo "La linia" NLI "es {" || LIN || "}."
end
end
say "Llegides (" NLI ") linies del fitxer (" FIN ")."
Halt : /* cerrar ordenadamente */
iRC = lineout( FIN ) /* close input file */
say "+++ Bye. Actual time is" Time()
return 0 /* always return a code */
File data entry into a Stem (complete)
/* Rexx */
/* trace ?r */
Producte = "Conversor de texte a HTM" ;
Versio = "v 1.0, 20050914" ;
Autor = "Sebastia Altemir Gubankov" ;
signal on Halt /* allow Ctrl-C end */
FileInDefault = "TXT2HTM.TXT"
FileOutDefault = "TXT2HTM.OUT"
parse UPPER Arg fIn fOut fTz Resto
Mostrar_Dades_Llegides = 1
FileIn = FileInDefault
FileOut = FileOutDefault
if ( ( fIn \= '' ) & ( fIn \= '-') ) then FileIn = fIn
/* input : data */
say "Anem a tractar el fitxer d'entrada" FileIn
Nl = 0
DadesIn. = ""
DadesIn.0 = 0
do while ( lines( FileIn ) )
Nl = Nl + 1
DadesIn.Nl = linein( FileIn )
end /* while loop */
iRC = lineout( FileIn ) /* close input file */
DadesIn.0 = Nl
say "Llegides" DadesIn.0 "linies del fitxer d'entrada" FileIn
if ( Mostrar_Dades_Llegides == 1 ) then do
i = 0
do while ( i < DadesIn.0 )
i = i + 1
l = length( DadesIn.i )
say "Linia" i "[ lng" l "] =" DadesIn.i
end
end
Halt : /* cerrar ordenadamente */
say "+++ Bye. Actual time is" Time()
return 0 /* always return a value */
Data conversion functions CDX
Conversions Character, Decimal i heXadecimal :
- C2D - char to decimal
c2d('81'x) -> 129 ; c2d('81') -> 14385 ;
- C2X - char to hex
c2x("REXX") returns the value 52455858 (the ASCII values for the characters)
Per operar string hexadecimals ...
5 *-* sH = 'AB' ;
>>> "AB"
6 *-* dV = X2D( sH ) ;
>>> "171"
7 *-* dV = dV + 6
>>> "177"
8 *-* sH = D2X( dV ) ;
>>> "B1"
|
Directory management
curdir = directory()
FirstDir = directory() /* remember where we are */
say "El directori original es" FirstDir
< move on the tree >
call directory FirstDir /* back to where we were */
FILESPEC
thisfile = "C:\WINDOWS\UTIL\SYSTEM.INI"
say "Tenim com a nom sencer :" thisdir
say "Amb FILESPEC, la darrera part es :" FILESPEC("name",thisdir)
REVERSE
path2 = "C:\WINDOWS\UTIL\SYSTEM.INI"
htap = reverse( path2 )
parse var htap last '\' .
say "Javier's version says :" reverse( last )
Compte !
c:\proves> type anar.cmd
/* REXX */
trace ?Errors
fn1 = "c:\Program Files\"
fn2 = "AT&T Network Client"
"cd " fn1
"cd " fn2
say "Return Code is {" RC "}."
|
|
SysCls and other functions
if RxFuncQuery('SysLoadFuncs') then do
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
end
Write the complete list of the funcions available ...
How can I know ?
Read this
Reference Handbook (OS/2),
that comes from
here
SysAddFileHandle SysFileTree SysRegisterObjectClass
SysAddRexxMacro SysGetCollate SysReleaseMutexSem
SysBootDrive SysGetEA SysReorderRexxMacro
SysClearRexxMacroSpace SysGetKey SysRequestMutexSem
SysCloseEventSem SysGetMessage SysResetEventSem
SysCloseMutexSem SysIni SysRmDir
SysCls SysLoadFuncs SysSaveObject
SysCopyObject SysLoadLibrary SysSaveRexxMacroSpace
SysCreateEventSem SysLoadRexxMacroSpace SysSearchPath
SysCreateMutexSem SysMapCase SysSetFileHandle
SysCreateObject SysMkDir SysSetIcon
SysCreateShadow SysMoveObject SysSetObjectData
SysCurPos SysNationalLanguageCompare SysSetPriority
SysCurState SysOpenEventSem SysSetProcessCodePage
SysDeregisterObjectClass SysOpenMutexSem SysShutDownSystem
SysDestroyObject SysOpenObject SysSleep
SysDriveInfo SysOS2Ver SysSwitchSession
SysDriveMap SysPostEventSem SysTempFileName
SysDropFuncs SysProcessType SysTextScreenRead
SysDropLibrary SysPutEA SysTextScreenSize
SysDropRexxMacro SysQueryClassList SysWaitEventSem
SysElapsedTime SysQueryEAList SysWaitForShell
SysFileDelete SysQueryProcessCodePage SysWaitNamedPipe
SysFileSearch SysQueryRexxMacro SysWildCard
SysFileSystemType SysQuerySwitchList
|
Visibilitat de variables en la crida a funcions + pas de parametres
Hem de diferenciar :
- funcions escrites en Rexx o funcions escrites en algun altre llenguatge, pero cridades des Rexx
- si son escrites en Rexx, poden ser internes o externes
- si son internes, poden començar amb procedure o no
Has access to all of your variables :
- internal Rexx function without a PROCEDURE statement
- external function not written in Rexx
Has acces to none of your variables :
- internal Rexx function with a PROCEDURE statement ( can use EXPOSE )
- external function written in Rexx
To have access to some variables, we use expose within a "PROCEDURE"
Keep in mind you can "expose" a complete stem !
Exemple de
expose :
Trabajo: procedure expose Cnt_Input Cnt_Output
Exemple de procedure
BigTrace = 1
lout = "JaJa."
iRC = MyTrace( fTz, lout, BigTrace )
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
MyTrace: procedure /* no vars visible */
parse arg FileTrace, Texto, ToFile /* read input parameters */
say Texto
if ( ToFile == 1 ) then
do
iRC = lineout( FileTrace, Texto )
end
return 0
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
Sintaxi crida de funcions
Atenció :
si cridem una funcio així :
"iRC = EnviarFichero( clientSocket, Fn, Ftz )"
haurem de rebre els arguments així :
"parse arg SendToSocket, FileName, FileTrace"
Atencio a les comes !
TCPIP & RxSock
The RxSock package is contained in the file rxsock.dll.
This file must be placed in a directory listed in your LIBPATH.
To get access to the functions in the RxSock package, execute the following Rexx code:
If RxFuncQuery("SockDropFuncs") then
do
iRC = RxFuncAdd("SockLoadFuncs","rxsock","SockLoadFuncs")
iRC = SockLoadFuncs()
vers = SockVersion()
say( "Rexx Socket Support package version :" vers )
end
To unload the DLL, call the SockDropFuncs() function and then exit all CMD.EXE shells.
Get PDF "Rexx TCP/IP Socket Library Functions" at
wu-wien,
ooRexx,
2012.
Browse
RxSock TCP/IP Socket Functions Reference online (v 4, Aug 2009)
Connect() return codes
99 EADDRNOTAVAIL The calling host cannot reach the specified destination.
97 EAFNOSUPPORT The address family is not supported.
114 EALREADY The socket is in nonblocking mode. A previous connection attempt has not completed.
88 ENOTSOCK The socket is not a valid socket descriptor.
111 ECONNREFUSED The destination host rejected the connection request.
115 EINPROGRESS socket is in nonblocking mode, and the connection cannot be completed immediately.
EINPROGRESS does not indicate an error.
4 EINTR Interrupted system call.
106 EISCONN Socket is already connected.
101 ENETUNREACH The network cannot be reached from this host.
110 ETIMEDOUT Establishing the connection timed out.
105 ENOBUFS There is no buffer space available.
95 EOPNOTSUPP The operation is not supported on socket.
Use this errno
tool
on your system !
### EXAMPLES:
###
### 1. To look up errno 22 on a system:
###
### errno 22
###
###
### 2. To look up errno ECONNRESET:
###
### errno ECONNRESET
Stem
A very special "array" ...
DogBreeds. = ''
DogBreeds.0 = 0
CALL addBreed peke "expensive rug rat"
CALL addBreed huskie "eats your cat"
if DogBreeds.0 > 0
then
do i = 1 to DogBreeds.0
key = DogBreeds.i
value = DogBreeds.key
SAY key value
end
return 0
/* Add indexable key-value pair to stem */
addBreed:
Procedure expose DogBreeds.
Parse arg breed characteristics
index = DogBreeds.0
index = index+1
DogBreeds.0 = index
DogBreeds.index = breed
DogBreeds.breed = characteristics
return
Do it in two steps:
ProcessStem: parse arg _ProcessStem_stem
call ProcessStem_sub _ProcessStem_stem
return result
ProcessStem_sub: procedure expose (_ProcessStem_stem)
stem = _ProcessStem_stem
/* write your code here */
return
pass a stem as a parameter
rc = Mostrar_Datos_Stem( "DadesIn." )
call Mostrar_Datos_Stem "DadesOut."
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
Mostrar_Datos_Stem:
parse arg miStem /* read input parameters */
lng = value( miStem || "0" )
say "+++ Stem has" lng "lines."
i = 0
do while ( i < lng )
i = i + 1
l = length( value( miStem || i) )
say "Linia" i "[ lng" l "] =" value( miStem || i )
end
return 0
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
store characters in a stem
If we want to search for a specific letter in an indicated position ...
word = "rexx"
len = length(word)
do i = 1 to len
chars.i = substr(word, i, 1)
end
/* Display all characters */
do i = 1 to len
say "chars."i "=" chars.i
end
Com llegir / escriure del / al Registre
See: C:\Program Files\ObjREXX\SAMPLES\registry.rex
Object Rexx Reference, Other Classes, WindowsRegistry Class
MAC change
/* trace ?r */
parse UPPER Arg newMACparam Verbose Resto
newMACparam = strip( newMACparam ) ;
myKey2 = "CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007"
/* Get system and version */
ret = syswinver()
parse var ret winsys winver
/* The registry editor name is different on NT 3.5 */
if winver \= 4 then
regeditor = "REGEDT32"
else regeditor = "REGEDIT"
FileControl = "\control"
FileNewKey = "\testuser"
/* do not use file extension on 95 */
if winsys = "WindowsNT" then do
FileControl = FileControl || ".reg"
FileNewKey = FileNewKey || ".reg"
end
r = .WindowsRegistry~new /* create a new registry object */
if r~InitCode \= 0 then exit /* leave if init failed */
/* r~Current_Key is initially set to HKEY_LOCAL_MACHINE */
/* Open the "HKEY_LOCAL_MACHINE\System" key */
myKey = "SYSTEM"
if r~open(,myKey,"QUERY WRITE") \= 0 then do
syskey = r~Current_Key /* save to close it */
if r~List(,keys.) = 0 then do /* Get a list of System's subkeys */
bk = r~open(,myKey2) /* open System's first subkey's Control key */
if bk \= 0 then do
r~setvalue(,"NetworkAddress",newMACparam) /* REG_SZ */
end
r~Close(bk) /* close Control key */
lout = "+++(1) End Close CONTROL key." ; iRC = mySay( lout, Verbose ) ;
end
r~Close(syskey) /* close System key */
end
return 0
/* winsystm.cls contains the WindowsRegistry class definition */
::requires "winsystm.cls"
WINFUNCS.DLL
Com posar icones al escritori ...
N.I.Y.
Folder :
Call SysCreateObject "WPFolder",
"INF Files",
"<WP_DESKTOP>",,
"OBJECTID=<INF_FILES>"
INF icon :
Call SysCreateObject "WPProgram",
title' ['path']',
"<INF_FILES>",,
"EXENAME=VIEW.EXE;PARAMETERS="name";STARTUPDIR="path";",,
"UPDATE"
PROG icon :
Call SysCreateObject "WPProgram",
title' ['path']',
"<INF_FILES>",,
"EXENAME=VIEW.EXE;PARAMETERS="name";STARTUPDIR="path";",,
"UPDATE"
Com obrir finestres amb Texte pregunta, botons "Yes/No", etc
/* Rexx */
iRC = RxMessageBox( "Continue or Not", "Mon Titol", "YesNo", "Question" )
say "RxMB return code =" iRC /* iRC = 6 on "yes", iRC = 7 on "no */
call RxFuncAdd InstMMFuncs, "OODialog", InstMMFuncs
call InstMMFuncs
message = "Hello, world !"
iRC = InfoMessage(message)
say 'Im rc =' iRC
iRC = ErrorMessage(message)
say 'Em rc =' iRC
iRC = YesNoMessage(message)
say 'YNm rc =' iRC
say "Adeu." time() "-" date()
return 0
::requires "OODPLAIN.CLS"
RANDOM
NUMERIC DIGITS 10
vIM=139968
vIA=3877
vIC=29573
LAST=42
parse arg n
If n < 1 Then Do
n = 1
End
Do i = 1 TO N
result = gen_random(100)
End
SAY result
EXIT
gen_random:
PROCEDURE EXPOSE LAST vIM vIA vIC
PARSE ARG n
LAST = (LAST * vIA + vIC) // vIM
return n * LAST / vIM
Escaping "&"
Com fer anar un String que conté un "&" ? El DOS l'agafa com a operador "AND" ...
A basic rule in Rexx is: Quote all commands to the underlying system.
The command is ECHO, so you start with:
'echo'
then, so that Rexx won't do substitution, you quote any string you don't want Rexx to see, as you did:
lout='John & Mary'
The result in your program should read:
'echo' lout
and you've followed all the Rexx rules. Rexx will pass the command with the
substituted string for the variable LOUT to the underlying OS, which may have
it's own rules for examining and substituting!
Generally speaking, and I'm no expert, you tell Windows to handle a string as a literal (without any substitution)
by putting it in double-quotes.
But to do that in Rexx, you either have to double the double-quotes OR put them in single quotes !
I'll use single quotes here, since that seems to be your style (MVS users tend to favor double-quotes),
so look closely:
/* rexx */
lout = "ramon & pere" ;
'echo' '"'lout'"'
return 0
Rexx access to DOS
You better do it from a CALL
envir vars
/* rexx */
myhn = value( 'COMPUTERNAME',, 'ENVIRONMENT' ) ; // get Hostname
say "This host's HOSTNAME is" myhn
mypth = value( 'PATH',, 'ENVIRONMENT' ) ; // get Path envir value
say mypth
return 0
Current directory
/* rexx */
mycwd = directory() ;
if ( Detall = 1 ) then say "Actual directory is" mycwd
IP
/* rexx */
fn = ".\f1.txt"
myipcmd = 'ipconfig | find "IP A" > ' fn
myipcmd ; // execute command
line = linein( fn )
say "linea = " line
parse var line inici ':' myip resto
/* remove trailing CR */
lng = length( myip )
myip = delstr( myip, lng ,1 )
/* display IP and correct length */
lng = length( myip )
say "myip = ["lng"]{" || myip || "}."
return myip
Redirect stdout and stderr (in DOS)
If we want no output at all ...
"CALL" command "> nul 2>&1"
Rexx access to MQ
OS/2 had MA31; w/NT had MA77.
Entorn
c:\> rexx -v
IBM Object REXX Interpreter Version 2.1.3
Build date: Mar 31 2004
Copyright (c) IBM Corporation 1996, 2004. All Rights Reserved.
c:\>dspmqver
Name: WebSphere MQ
Version: 6.0.1.1
CMVC level: p600-101-060504
BuildType: IKAP - (Production)
Instalació
Set PATH to reach for RXMQN.DLL (acces to a local QMgr)
and/or RXMQT.DLL (client access to a server QMgr).
Codi
/* Define the Rexx/MQ interface to Rexx */
rcc = RXFuncadd('RXMQNINIT','RXMQN','RXMQNINIT')
say '>>> FuncAdd() rc=' rcc
/* Initialise the interface */
RXMQNTRACE = ''
rcc= RXMQNINIT()
say '>>> Init() rc=' rcc
/* Connect to Queue Manager - RAHN */
qMgrName = "QMANAGER.AS400"
RXMQNTRACE = ''
rcc = RXMQNCONN( qMgrName )
say '>>> Conn() rc=' rcc
/* Open Queue N1 for Inquire Access Only, tracing Object Descriptor accesses */
queueName = "ALBERTQ"
iod.on = queueName
iod.ot = MQOT_Q
RXMQNTRACE = ''
rcc = RXMQNOPEN('iod.', mqoo_inquire, 'h1', 'ood.')
say '>>> Open() rc=' rcc 'H=' h1
/* Show the name of the Queue which is using handle 1 */
RXMQNTRACE = ''
atrin = mqca_q_name
atrou = ''
rcc = RXMQNINQ(h1, atrin, 'atrou' )
say 'Inq() rc=' rcc 'Atr' atrin 'Setting <'atrou'>'
...
/* Stop access to the Queue */
RXMQNTRACE = ''
rcc = RXMQNCLOSE(h3, mqco_none)
say 'Close() rc=' rcc
/* Disconnect from the QM (Closing h1 in the process) */
RXMQNTRACE = ''
rcc = RXMQNDISC()
say 'Disc() rc=' rcc
/* Remove the Interface functions from the Rexx Workspace ... */
RXMQNTRACE = 'TERM'
rcc = RXMQNTERM()
say 'Term() rc=' rcc
Call SAG.DLL from SAG.REX
How to code a DLL
N.I.Y.
How to call a (own) DLL from Rexx
N.I.Y.
Sample : counting given words
cnt = 0
keep. = 0
do while text <> ''
parse var text nextword text
if keep.nextword = 0 then
do
cnt = cnt + 1
list.cnt = nextword
end
keep.nextword = keep.nextword + 1
end
do i = 1 to cnt
nextword = list.i
say nextword keep.nextword
end
Calculator
c:\\Rexx\CalcR> type calc.rex
/* rexx */
X = 'input BYE to quit'
do until X = 'BYE' ;
interpret 'say' X ; pull X ;
end
Rexx on a pipe
When you put the REXX interpreter into a pipeline, it connects STDIN, STDOUT and STDERR
so that they become available to the rexx programs run by this interpreter.
Example (myprog is a rexx script):
ps -eF | grep amq | rexx myprog
Other example:
ps -eF | grep amq | rexx -e "signal on notready;do forever;parse pull . pid .; say 'pid=' pid; end; notready:return"
Gives as output:
pid= 4797
|
System functions
|
Top
|
|
See
ftp://sdfrxs02.boeblingen.de.ibm.com/rexx/OREXXLinux/i386/readme.txt (11/02/03)
12.0 LIST OF REXX UTILITY FUNCTIONS
=================================================================
Function | Exists on platforms: |
Name: | OS/2 | Windows | UNIX | Remarks
--------------------------+------+---------+------+--------------
SysAddFileHandle | YES | YES | NO |
SysAddRexxMacro | YES | YES | YES |
SysBootDrive | YES | YES | NO |
SysClearRexxMacroSpace | YES | YES | YES |
SysCloseEventSem | YES | YES | YES |
SysCloseMutexSem | YES | YES | YES |
SysCls | YES | YES | YES |
SysCopyObject | YES | NO | NO |
SysCreateEventSem | YES | YES | YES |
SysCreateMutexSem | YES | YES | YES |
SysCreateObject | YES | NO | NO |
SysCreatePipe | NO | NO | YES |
SysCreateShadow | YES | NO | NO |
SysCurPos | YES | YES | NO |
SysCurState | YES | YES | NO |
SysDeregisterObjectClass | YES | NO | NO |
SysDestroyObject | YES | NO | NO |
SysDriveInfo | YES | YES | NO |
SysDriveMap | YES | YES | NO |
SysDropFuncs | YES | YES | YES |
SysDropLibrary | YES | YES | NO |
SysDropRexxMacro | YES | YES | YES |
SysDumpVariables | YES | YES | YES |
SysElapsedTime | YES | NO | NO |
SysFileDelete | YES | YES | YES |
SysFileSearch | YES | YES | YES |
SysFileSystemType | YES | YES | NO |
SysFileTree | YES | YES | YES* |
SysFromUnicode | NO | YES | NO |
SysToUnicode | NO | YES | NO |
SysGetErrortext | NO | YES | YES**|
SysFork | NO | NO | YES |
SysGetCollate | YES | YES | NO |
SysGetEA | YES | NO | NO |
SysGetFileDateTime | YES | YES | YES |
SysGetKey | YES | YES | YES |
SysGetMessage | NO | YES | YES |
SysGetMessageX | NO | NO | YES |
SysGetpid | NO | NO | YES+ | use SysQueryProcess instead;
SysIni | YES | YES | NO |
SysLoadFuncs | YES | YES | YES |
SysLoadLibrary | YES | YES | NO |
SysLoadRexxMacroSpace | YES | YES | YES |
SysMapCase | YES | YES | NO |
SysMkDir | YES | YES | YES |
SysMoveObject | YES | NO | NO |
SysNationalLanguageCompare| YES | YES | NO |
SysOpenEventSem | YES | YES | YES |
SysOpenMutexSem | YES | YES | YES |
SysOpenObject | YES | NO | NO |
SysPostEventSem | YES | YES | YES |
SysProzessType | YES | YES | NO |
SysPulseEventSem | YES | YES | NO |
SysPutEA | YES | NO | NO |
SysQueryClassList | YES | NO | NO |
SysQueryEAList | YES | NO | NO |
SysQueryExtLIBPATH | YES | NO | NO |
SysQueryProcess | YES | YES | YES* |
SysQueryProcessCodePage | YES | YES | NO |
SysQueryRexxMacro | YES | YES | YES |
SysQuerySwitchList | YES | NO | NO |
SysRegisterObjectClass | YES | NO | NO |
SysReleaseMutexSem | YES | YES | YES |
SysReorderRexxMacro | YES | YES | YES |
SysRequestMutexSem | YES | YES | YES |
SysResetEventSem | YES | YES | YES |
SysRmDir | YES | YES | YES |
SysSaveObject | YES | NO | NO |
SysSaveRexxMacroSpace | YES | YES | YES |
SysSearchPath | YES | YES | YES |
SysSetExtLIBPATH | YES | NO | NO |
SysSetFileDateTime | YES | YES | YES |
SysSetFileHandle | YES | NO | NO |
SysSetIcon | YES | NO | NO |
SysSetObjectData | YES | NO | NO |
SysSetPriority | YES | YES | NO |
SysSetProcessCodePage | YES | YES | NO |
SysShutDownSystem | YES | YES | NO |
SysSleep | YES | YES | YES |
SysStemCopy | YES | YES | YES |
SysStemDelete | YES | YES | YES |
SysStemInsert | YES | YES | YES |
SysStemSort | YES | YES | YES |
SysSwitchSession | YES | YES | NO |
SysSystemDirectory | YES | NO | NO |
SysTempFileName | YES | YES | YES |
SysTextScreenRead | YES | YES | NO |
SysTextScreenSize | YES | YES | NO |
SysUtilVersion | YES | YES | YES |
SysVersion | YES | YES | YES |
SysVolumeLabel | YES | YES | NO |
SysWait | NO | NO | YES |
SysWaitEventSem | YES | YES | YES |
SysWaitForShell | YES | NO | NO |
SysWaitNamedPipe | YES | YES | NO |
SysWinDecryptFile | NO | YES | NO |
SysWinEncryptFile | NO | YES | NO |
SysWildCard | YES | YES | NO |
==========================+======+=========+======+==============
SysOS2Ver | YES | NO | NO | use SysVersion instead;
SysWinVer | NO | YES | NO | use SysVersion instead;
SysLinVer | NO | NO | YES++| use SysVersion instead;
=================================================================
Legend: * <=> works differently;
** <=> new function;
+ <=> AIX only.
++ <=> Linux only.
=================================================================
|
El REXX i el rus
Problema típic de encoding. Ha de quadrar el encoding del file system, el del shell, i el del texte del rexx.
T'aconsello que tot sigui utf8 sempre i per a tot. Allò que no ho sigui que ho modifiquis.
El texte del rexx ho pots canviar amb el notepad++
El shell el pots canviar amb chcp.
Jo tinc tots els shells en utf8 per defecte.
El file system o millor dit els filenames és més laboriós.
Shell
chcp 65001
interface to other languages ...
This chapter describes how to interface applications to Rexx or extend the Rexx language by using Rexx C++ application programming interfaces (APIs).
As used here, the term application refers to programs written in C++.
url
Pending
- get PATH and verify it is shorter than 1023 chars long - \\rexx\windows_path_max_length
- pattern matching with wildcards
- com fer Delay() ?
- i un ">" ?
- com convertir un CMD en un EXE ?
- com saber quin Sistema Operatiu tenim a sota ?
Per fer servir "rm -f" (linux) o "del /f" (dos)
Instalació Rexx
Get
ooRexx 4.1.2
&
RxSock() v1.4
CD Eines-2 - OjbRexx - or T42:\Fonts\Rexx - or gSpace(ruta66).
D:\ObjRexx\Win_V2.1.3\setup.exe = 16.507.617 = Developer Edition 2.1.3.0
PARSE version says "OBJREXX 6.00 31 Mar 2004"
c:\> rexx -v
IBM Object REXX Interpreter Version 2.1.3
Build date: Mar 31 2004
labss2 (RH v4, 32-bit)
Comencem amb
3576601 Nov 15 14:09 oorexx-3.1.1-1.el4.rf.i386.rpm
124168 Apr 1 2004 RxSock-1.4.tar.gz
Instalem
[root@labss2 rexx]# cat /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
[root@labss2 rexx]# rpm -ivh oorexx-3.1.1-1.el4.rf.i386.rpm
warning: oorexx-3.1.1-1.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:oorexx ########################################### [100%]
[root@labss2 rexx]# rexx -v
Open Object Rexx Interpreter Version 3.1.1 for LINUX
Build date: Jan 15 2007
[root@labss2 rexx]#
Per RxSock:
[root@labss2 rexx]# tar -zxzf RxSock-1.4.tar.gz
RH64b
Comencem amb
[sebas@rhv6-64b rexx]$ ls -l
-rwx------. 1 sebas sebas 2563905 Nov 13 10:55 ooRexx-4.1.2.opensuse1210.x86_64.rpm
Instalem:
[sebas@rhv6-64b rexx]$ rpm -i --test ooRexx-4.1.2.opensuse1210.x86_64.rpm
[root@rhv6-64b prod]# rpm -ivh ../ooRexx-4.1.2.opensuse1210.x86_64.rpm
Preparing... ########################################### [100%]
1:ooRexx ########################################### [100%]
Starting rxapi: /usr/bin/rxapi: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/bin/rxapi)
/usr/bin/rxapi: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/bin/rxapi)
[FAILED]
warning: %post(ooRexx-4.1.2-8330.opensuse1210.x86_64) scriptlet failed, exit status 1
[root@rhv6-64b prod]# rpm -i --test ../ooRexx-4.1.2.opensuse1210.x86_64.rpm
package ooRexx-4.1.2-8330.opensuse1210.x86_64 is already installed
[root@rhv6-64b prod]# rexx -v
rexx: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/ooRexx/librexx.so.4)
rexx: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib64/ooRexx/librexxapi.so.4)
rexx: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/ooRexx/librexxapi.so.4)
[root@rhv6-64b lib64]# ls -l /lib64/libc.so.6
lrwxrwxrwx. 1 root root 12 Sep 27 19:25 /lib64/libc.so.6 -> libc-2.12.so
[root@rhv6-64b lib64]# ldd /usr/bin/rexx
/usr/bin/rexx: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/ooRexx/librexx.so.4)
/usr/bin/rexx: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib64/ooRexx/librexxapi.so.4)
/usr/bin/rexx: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/ooRexx/librexxapi.so.4)
linux-vdso.so.1 => (0x00007fff425ff000)
librexx.so.4 => /usr/lib64/ooRexx/librexx.so.4 (0x00007f6ffbe25000)
librexxapi.so.4 => /usr/lib64/ooRexx/librexxapi.so.4 (0x00007f6ffbc0e000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003df4800000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003df4c00000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003e00c00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003df4400000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003dfe400000)
libc.so.6 => /lib64/libc.so.6 (0x0000003df4000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003df3800000)
Ubuntu (MARS)
- get ooRexx-4.2.0-1.ubuntu1310.x86_64.deb
from here
- go to folder/file and double-click to start
- we get
nicolau@nicolau-desktop:~$ rexx -v
Open Object Rexx Version 4.2.0
Build date: Dec 29 2013
Addressing Mode: 64
Copyright (c) IBM Corporation 1995, 2004.
Copyright (c) RexxLA 2005-2013.
All Rights Reserved.
This program and the accompanying materials are made available under
the terms of the Common Public License v1.0 which accompanies this
distribution or at
http://www.oorexx.org/license.html
Raspberry
pi@R4:~/soft/rexx $ sudo apt install libregina3 regina-rexx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libregina3 regina-rexx
0 upgraded, 2 newly installed, 0 to remove and 183 not upgraded.
Need to get 370 kB of archives.
After this operation, 1,132 kB of additional disk space will be used.
Get:1 http://ftp.cica.es/mirrors/Linux/raspbian/raspbian buster/main armhf libregina3 armhf 3.6-2.1 [174 kB]
Get:2 http://ftp.cica.es/mirrors/Linux/raspbian/raspbian buster/main armhf regina-rexx armhf 3.6-2.1 [195 kB]
Fetched 370 kB in 1s (512 kB/s)
Selecting previously unselected package libregina3.
(Reading database ... 169971 files and directories currently installed.)
Preparing to unpack .../libregina3_3.6-2.1_armhf.deb ...
Unpacking libregina3 (3.6-2.1) ...
Selecting previously unselected package regina-rexx.
Preparing to unpack .../regina-rexx_3.6-2.1_armhf.deb ...
Unpacking regina-rexx (3.6-2.1) ...
Setting up libregina3 (3.6-2.1) ...
Setting up regina-rexx (3.6-2.1) ...
Processing triggers for man-db (2.8.5-2) ...
I tenim :
pi@R4:~/soft/rexx $ rexx -v
REXX-Regina_3.6 5.00 31 Dec 2011
Alguns exemples interessants de codi en Rexx ...
DirS -
Codi
Apuntar en el Help on fica el fitxer temporal.
MQ Client
requires MQIC32.DLL
P4:\Delphi\MQ\
T42:\Delphi\MQ_client\
Other scripting tools
Intentem comparar el rexx amb ...
Rexx is a structured high-level programming language that was designed to be both easy to learn and easy to read.
Rexx is widely used as a glue language, macro language, and is often used for processing data and text and generating reports.
Rexx is the primary scripting language in some operating systems, and is also used as an internal macro language in some other software.
wiki.
Perl is a high-level, general-purpose, interpreted, dynamic programming language,
developed as a general-purpose Unix scripting language to make report processing easier.
Perl borrows features from other programming languages including C, shell scripting (sh), AWK, and sed.
The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools, facilitating easy manipulation of text files.
wiki.
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
Python aims to combine "remarkable power with very clear syntax", and its standard library is large and comprehensive.
Its use of indentation for block delimiters is unique among popular programming languages.
Python is often used as a scripting language, but is also used in a wide range of non-scripting contexts.
wiki.
Apache Ant is a software tool for automating software build processes.
It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects.
Ant uses XML to describe the build process and its dependencies.
wiki.
Links
- Mike at wiki
- RexxInfo = the one-stop site for Rexx information.
- Wikipedia
&
Open ooRexx ;
Programming Guide ...
pdf,
on-line.
-
On es el Rexx "lliure" ???
OoRexx
homepage,
download OO Rexx.
SourceForge, with 14 MB docu ;
V 4.2.0, 2014-02-22
- Forums :
DBforums,
google
-
Guidance says :
In Windows system, Reginald, a free REXX intepreter comes with a GUI library, also could be a rapid programming tool.
Forum
-
RexxLA
links
-
Patrick McPhee - w32funcs = function library for Regina => access to Registry.
- How to download it ? (ONLY to Update it - otherwise ...)
Inter edition = basic package
Dev edition = basic + GUI classes + RSRC workshop + GUI dev + COBOL API.
- Windows (intranet) -
URL -
Object Rexx version 2.1.3 for Windows [ 16.507.617 setup.exe - gone 12/2006 ]
- Windows (demoPkg) -
3.536.743 ord1023u.exe = Object REXX for Windows Development Edition v 1.0.2.3
7.650.492 orxd1023.exe = Object REXX for Windows Development Edition v 1.0.2.3
2.013.672 ori1023u.exe = Object REXX for Windows Interpreter Edition v 1.0.2.3
2.271.048 orxi1023.exe = Object REXX for Windows Interpreter Edition v 1.0.2.3
FTP directory /rexx/OREXXWin/ at sdfrxs02.boeblingen.de.ibm.com : [gone]
30,321,432 orxd2100.ZIP - developer
16,605,576 orxi2100.ZIP - interpreter
18,270,097 orxd213u.exe - version 2.1.3 update, developer
17,259,921 orxi213u.exe - version 2.1.3 update, interpreter
- Linux -
(orexx-2.3.3.0-1.i386.rpm is 3.8 MB)
,
(orexx-2.3.4.0-3.i386.rpm is 3.9 MB)
here
Requires : 11 MB disk,
kernel 2.2.14,
libc.so.6.1.1,
ld.so.1.9.5-13.
- The Rexx Language - IBM Hursley. Tons of links.
- AAT book - Album of Algorithms and Techniques.
- Regina @ SourceForge
- github
- Nice
page - Rexx2Exe and many more :
Reginald interpreter, Programmer Center,
Function Libraries (GUI, ODB, RexxInet, RexxSock, RxTwain,
RxMIDI, RxMidiIO, Speech, Math, Rx(Un)Zip, RxComm, Float).
Moved here
- Nice forum.
Another,
Internal
-
Complete index
- Tutorials :
- How to call ...
from C
- EDM2 :
The Developer's Best Friend,
Tips and Tricks (for OS/2)
-
OS/2 eZine and
Rexx
- Microsoft
samples
- Forum
search
-
Samples
-
Blue pages
API {intra}
- Infrastructure for
automating
Windows applications
- File Library
OS/2
-
Multi-platform I/O details
- Google
Comp Lang Rexx
- ANSI compliant, fast, free classic Rexx interpreter for Windows :
Regina
- Rexx [nice]
summary.
- Internal
support for date() and time() new formats.
- Rexx tutorial
- Stable RPM Based Linux Distros for the Raspberry Pi 4
-
Raspberry forums on Rexx -> use Regina
- Google
or AllTheWeb
or DuckDuckGo
- Tinet
- Previous page
- Back to main page
- Site map
- Escriu-me !
Fet en Rexx : ( CALANY.CMD & CALMES.CMD a "\\w500\Rexx\Cal" )
| 2019 |
| | L | M | X | J | V | S | D |
L | M | X | J | V | S | D |
L | M | X | J | V | S | D |
L | M | X | J | V | S | D |
L | M | X | J | V | S | D |
L | M | X | J | V | S | D |
| Gen |
| 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | | | | | | | | | | |
| Feb |
| | | | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | | | | | | | | | | |
| Mar |
| | | | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
| | | | | | |
| Abr |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | | | | | | | | | | | | |
| May |
| | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | | | | | | | | | |
| Jun |
| | | | | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
| | | | | | |
| Jul |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | | | | | | | | | | | |
| Ago |
| | | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | | | | | | | | |
| Sep |
| | | | | | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | | | | | | |
| Oct |
| 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | | | | | | | | | | |
| Nov |
| | | | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | | | | | | | | |
| Dec |
| | | | | | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | | | | | |