Object Rexx [IBM Object Rexx] is an object-oriented scripting language for OS/2, designed by IBM and descended from classic Rexx [IBM Rexx]. It can be used merely for writing OS/2 command files, but is versatile enough for many more sophisticated uses. The IFS has used classic Rexx for some time as the scripting language for its GoServe server. GoServe can also run Object Rexx. Given the language's long-lived instances, this was a particularly fortunate combination.
Object Rexx is a conventional OOP language, similar to Smalltalk in its
semantics. The syntax is a little bizarre, being dictated by the need
for upward compatibility with classic Rexx. An example is shown below,
showing how we implement
::class IntegerField ::method init expose value has_errors value = '' has_errors = .false return ::method setValue expose value has_errors use arg v value = v if datatype(v,'w') then has_errors = .false else has_errors = .true return ::method getValue expose value return value ::method emit expose value has_errors use arg output_stream output_stream~charout( '<INPUT TYPE=TEXT' ) output_stream~charout( ' VALUE=' value||'>' ) if has_errors then output_stream~lineout( '<IMG SRC="big_red_arrow.gif">' ) else output_stream~lineout() return
init method is a constructor, called when an
IntegerField is created.
expose marks the names
it as instance variables, so we see that
init is setting
setValue takes one argument
syntax-checks it via the built-in
datatype function, setting the
new value if OK, and the error flag otherwise.
getValue is an
access method, returning the value. Finally,
emit is the method
for displaying oneself as HTML: it takes a stream as argument, and
writes appropriate text to it. In Object Rexx, streams are objects: the
~ indicates calls to the stream methods
lineout, for writing strings and strings with line terminators