For convenience, NetRexx provides some special names for naming commonly-used concepts within terms. These are only recognized if there is no variable of the same name previously seen in the current scope (this allows the set of special words to be expanded in the future, if necessary, without invalidating existing variables). These names are not reserved; they may be used as variable names instead, if desired.
There are also two 'special methods' that are used when constructing objects, and constructors for the primitive types.
The following special names are allowed in NetRexx programs.
if ask='yes' then say 'OK'
In the Java environment, ask is simply a shorthand for 'RexxIO.Ask()'.
foo=char[7] say foo.length /* would say '7' */
Note that you can get the length of a String or Rexx object with the same syntax (unless OPTIONS STRICTARGS is in effect). In these cases, however, a length() method is being invoked.
blob=int[3] /* 'blob' refers to an array of 3 ints */ blob=null /* 'blob' is still of type int[], but refers to no real object */
The 'null' value may be considered to represent the state of being uninitialized. That is, the state of a variable after DROP in Rexx.
If 'options binary' is in effect, a java.lang.String is returned.
method printit(x) say 'it' -- modification super.printit(x) -- and now the usual processing
super can only appear as the first item in a compound reference term.
word="hello" /* 'word' now refers to "hello" */ say word.substr(3) /* invokes substr method on "hello" */
then the method 'substr' in class Rexx is started, with argument '3', and with the properties of the object "hello" available to it. These may be accessed simply by name, or (more explicitly) by prefixing the name with 'this.'. Using 'this.' often makes a method more readable, especially when several objects of the same type are being manipulated in a method.
If a property being referenced is in fact owned by a superclass of the current class, then then prefix 'this.' is the simplest way to indicate that name refers to a property rather than to a local variable. (You could also qualify it by 'super.', or the name of the superclass.)
1. A word describing the language. The first seven letters will be the characters 'NetRexx', and the remainder may be used to identify a particular implementation or language processor. This word may not include any periods.
2. The language level description. For example, '1.01'.
3. Three tokens describing the language processor release date in the same format as the default for the Rexx date() function. For example, '3 Jan 1997'.
If 'options binary' is in effect, a java.lang.String is returned.
With the exception of 'length', the special names may only be used alone or as the first item in a compound reference.
Constructors (methods used for constructing objects) in NetRexx must invoke a constructor of their superclass before making any modifications to the current object (or invoke another constructor in the current class).
This is simplified and made explicit by the provision of the special method names 'super' and 'this', which refer to constructors of the superclass and current class respectively. These special methods are only recognized when used as the first, method call, instruction in a constructor. See "Methods and constructors".
In addition, NetRexx provides special constructors for the primitive types that allow bitwise construction of primitives. For example:
i=int 77 c=char(i) -- c is now the character 'M' j=int(c) -- j is now the integer 77
Note that the conversion
j=int c
would have failed, as 'M' is not a number. The argument to a primitive constructor must be a primitive.
[ previous section | contents | next section ]
From 'netrexx.doc', version 1.00.
Copyright(c) IBM Corporation, 1996, 1997. All rights reserved. ©