A NetRexx program permits the definition of multiple classes and methods, and also permits the writing of 'low boilerplate' programs by providing a default class and method as appropriate. The simplest documented NetRexx program might therefore be:
/* This is a very simple NetRexx program */ say 'Hello World!'
More generally, a NetRexx program consists of:
A class definition comprises:
Methods may contain any instructions, except the CLASS, METHOD, and PROPERTIES instructions and those allowed in the prologue.
For example:
/* A program with two classes */ import java.applet. -- for exampleclass testclass extends Applet i=int -- property (instance) variable j=int 3 -- this one is initialized to 3
method start say 'I started'
method stop say 'I stopped'
class anotherclass method testing loop i=1 to 10 say '1, 2, 3, 4...' if i=7 then return end return
method anothertest say '1, 2, 3, 4'
Note that a RETURN instruction implies no static scoping; the content of a method is ended by a METHOD (or CLASS) instruction, or by the end of the source stream.
The following defaults are provided:
In other words, a 'stand-alone' application can be written without explicitly providing the class and method instructions for the first method to be executed.
In the Java environment, the 'main' method in a stand-alone application is passed the words forming the command string as a String array. When NetRexx provides the method instruction by default, it also constructs a Rexx string from this array of words, with a blank added between words, and assigns the string to the variable 'arg'.
The command string may also have been edited by the underlying operating system environment; certain characters may not be allowed, multiple blanks or whitespace may have been reduced to single blanks, etc.
Language processors may provide option(s) to prevent, or warn of, these defaults being applied, as desired.
[ previous section | contents]
From 'netrexx.doc', version 1.00.
Copyright(c) IBM Corporation, 1996, 1997. All rights reserved. ©