Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object REXX
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Instructions === As in classic Rexx, there are assignment instructions, keyword instructions and command instructions. In line with the desire to keep the language small, ooRexx 5.0.0 has only thirty keyword instructions.<ref name=":2" /> Unlike many other languages, no keywords are reserved, so keyword instructions such as <code>DO</code>, <code>SAY</code>, <code>END</code> and <code>IF</code> for example can be used as variable names during an assignment. This avoids having to memorize a long list of [[Reserved word|reserved words]].<ref name=":4" /> An assignment is used to set or change the value of a variable. The equal sign (<code>=</code>) is used to create an assignment instruction which can be used in combination with eleven operators for extended assignment sequences such as <code>+=</code>, <code>-=</code>, <code>*=</code> and others. Keyword instructions such as <code>ARG</code>, <code>PARSE</code>, <code>PULL</code> or <code>USE</code> have the same effect as assignments.<ref name=":2" /> In cases where an instruction is neither an assignment nor a keyword instruction, it must be a string literal or a valid expression which is considered a command instruction, which causes the interpreter to pass the string to the operating system for execution and set a variable <code>RC</code> for the return code. In addition, the <code>ADDRESS</code> instruction allows commands to be redirected to specific command environments such as [[Bourne shell|Bourne Shell]], [[Bash (Unix shell)|Bash]], [[Z shell|Z-Shell]], [[Cmd.exe|Command Prompt]] and others, some editors including [[ISPF]], [[Time Sharing Option|TSO]] EDIT, [[XEDIT]] and its [[XEDIT#PC and Unix adaptations|adaptations]], as well as intercepting errors.<syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> a = "hello world" /* assignment instruction */ do i = 1 to 2 /* keyword instruction "DO" */ say "round #" i":" a /* keyword instruction "SAY" */ end /* keyword instruction "END" */ "echo Hello World" /* command to operating system */ say "RC:" rc /* command's numeric return code */ </syntaxhighlight>In addition to the three instruction types of classic Rexx, ooRexx adds [[Directive (programming)|directive]]{{efn|As of 5.0.0, ooRexx has the <code>::ANNOTATE</code>, <code>::ATTRIBUTE</code>, <code>::CLASS</code>, <code>::CONSTANT</code>, <code>::METHOD</code>, <code>::OPTIONS</code>, <code>::REQUIRES</code>, <code>::RESOURCE</code> and <code>::ROUTINE</code> directives.}} instructions which need to be placed at the end of the program. After loading and the syntax check, the interpreter executes all defined directives to set up the execution environment for the program before further instructions are executed. Directives can be used to define [[Object REXX#Procedure and function|routines]], [[Object REXX#Class and Method|classes]], [[Object REXX#Class and Method|methods]], attributes or execution options like the number of digits to use in arithmetics. To make directive instructions readily recognizable, they are introduced with two consecutive colons (<code>::</code>).<ref name=":2" /> To facilitate the [[reusability]] of code, the <code>::REQUIRES</code> directive allows the integration of another Rexx program (also known as a package) or an external (native) library. This directive causes the interpreter to make every routine and class that specifies the <code>PUBLIC</code> option of the denoted Rexx program (package) to become directly accessible. External packages usually use the file extension <code>.cls</code>, for example <code>::requires "csvstream.cls"</code> or <code>::requires "json.cls"</code>. Some [[Object REXX#External packages and libraries|external packages and libraries]] are delivered with the ooRexx interpreter.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)