There are numerous
Descriptions are provided for the initialize method of each class. The initialize method is usually invoked during class construction. The class construction parameters are passed to the initialize method. The initialize method is only invoked directly by an explicitly derived class. The randomSequence example program explicitly invokes the initialize method of the vector class.
The following built-in classes are provided.
Aggregate | a generic collection base class |
BitVector | a condensed vector of boolean values of a fixed size -- 4096 bits |
Callback | abstract callback class associated with an external program |
CharacterVector | a vector of one-byte wide characters |
Clipboard | a clipboard text encapsulation |
Comparator | abstract class for comparing two items |
Console | console stream |
ContextVector (aka StackTrace) |
system call vector access class |
DriveContext (aka Disk, DiskContext, Drive) |
drive (disk) reference context |
Emitter | an output stream emitter |
Exception | exception information that can be referenced by catch condition handlers |
ExternalClass | a class that is supported by an external program |
File | file information |
FolderContext (aka Directory, DirectoryContext, Folder) |
folder (directory) reference context |
InLineFile | an input file that is accessed as a sequence of lines |
InOutLineFile | a file that is updated as a sequence of lines |
InStream | default input stream (standard input) |
List | a collection of heterogeneous items. |
Map | a collection of heterogeneous items. a map is indexed by a string value |
Math | various mathematic functions (natural logarithm, sine, cosine, etc) and constants (π, e, Φ, γ) |
Object | a generic object base class |
OrderedVector | an ordered collection of items multiple items may have the same value |
OutLineFile | an output file that is accessed as a sequence of lines |
OutStream | default output stream (standard output) |
Pattern | a regular expression pattern |
PatternMatch | matching information for a regular expression pattern search |
Queue | a collection of heterogeneous items, that is accessed at the front or end. |
Set | an ordered collection of unique items |
Socket | a TCP/IP socket send/receive class |
Stack | a collection of heterogeneous items, that is accessed at the end. |
System | system information |
SystemPropertyMap | a collection of system properties (aka environment variables) a map is indexed by a string value |
Table | a two dimensional table containing an arbitrary number of rows, and a fixed number of columns |
Tree | a hierarchical object |
Vector | a collection of heterogeneous items. |
WideCharacterVector | a vector of two-byte wide characters |
The following table uses indentation to indicate built-in class derivation structure. Methods in a base class can be used in a derived class.
Object | a generic object base class |
.. Aggregate | a generic collection base class |
.... List | a collection of heterogeneous items. |
...... InOutLineFile | a file that is updated as a sequence of lines |
...... Queue | a collection of heterogeneous items, that is accessed at the front or end. |
.... Map | a collection of heterogeneous items. a map is indexed by a string value |
...... SystemPropertyMap | a collection of system properties (aka environment variables) a map is indexed by a string value |
.... OrderedVector | an ordered collection of items multiple items may have the same value |
.... Vector | a collection of heterogeneous items. |
...... ContextVector (aka StackTrace) |
system call vector access class |
...... InLineFile | an input file that is accessed as a sequence of lines |
...... OutLineFile | an output file that is accessed as a sequence of lines |
...... Stack | a collection of heterogeneous items, that is accessed at the end. |
.......... DriveContext (aka DiskContext) |
drive (disk) reference context |
.......... FolderContext (aka DirectoryContext) |
folder (directory) reference context |
.... Set | an ordered collection of unique items |
.. BitVector | a condensed vector of boolean values of a fixed size -- 4096 bits |
.. Callback | abstract callback class associated with an external program |
.. CharacterVector | a vector of one-byte wide characters |
.. Clipboard | a clipboard text encapsulation |
.. Comparator | abstract class for comparing two items |
.. Math | various mathematic functions (sine, cosine, etc) and constants (π, e, Φ, γ) |
.. Pattern | a regular expression pattern |
.. PatternMatch | matching information for a regular expression pattern search |
.. Emitter | an output stream emitter |
.... Console | console stream |
.... OutStream | default output stream (standard output) |
.. Exception | exception information that can be referenced by catch condition handlers |
.. ExternalClass | a class that is supported by an external program |
.. File | file information |
.. InStream | default input stream (standard input) |
.. System | system information |
.. Table | a two dimensional table containing an arbitrary number of rows, and a fixed number of columns |
.. Tree | a hierarchical object |
.. WideCharacterVector | a vector of two-byte wide characters |
Socket | a TCP/IP socket client send/receive class |
Numerous classes are aggregates that store an arbitrary number of other items. Each item is a Rexx value or an instance of another object.
A common set of methods are used within these classes. The methods, that are available for each aggregate class, are listed in their class description.
Observe: aggregate references often involve index values. The Rexx language consistently indexes arguments and string positions with an origin of 1. Consequently, within aggregate methods an index value of 1 references the first item stored in the aggregate. The index must be in the range 1 through size(), inclusive.
Warning: an objection condition is raised when an index is specified that is not within the aggregate's bounds.
add( [ item [ , item [, ... ] ] ) | adds zero or more items, at the end. returns instance reference. |
addAggregate( aggregateInstance ) | adds all items from another aggregate, at the end. the size() and getAt() methods of the other aggregate are used to acquire items. returns instance reference. |
addDelimitedString( string, delimitingValue ) | adds items within a delimited value string, at the end. if either string is empty nothing is added. if the delimiter is a comma, the string is treated as a comma-separated value string. if the delimiter is a newline character ('0a'x) a series of lines (1) is acquired. returns instance reference. |
addFirst( item ) | adds item in front of all others. returns instance reference. |
addStem( stem ) | adds stem collection, at the end. stem.0 is #items, stem.1 is first item, etc. returns instance reference. |
addSystemQueue() | adds items, and removes them, from the external data queue. items are added at the end. returns instance reference. |
average() | returns average of items. uses a toString call per item if necessary. all values must be numeric. |
contains( item ) | returns 1 if the aggregate contains item, and 0 otherwise |
copyAggregate( aggregateInstance ) | removes all items. adds all items from another aggregate. a different type of aggregate can be copied. returns instance reference. |
count( item ) | returns #items that strictly match item. |
exchange( index1, index2 ) | exchanges two item values. returns instance reference. |
exists( index ) | returns "1" if the indexed element is in the aggregate, and "0" otherwise. |
getAt( index ) | gets indexed item. |
find( item ) | returns index of item. an index of 0 indicates the item was not found. |
initialize( [ item, item, ... ] ) | prepares the aggregate instance, and optionally adds a series of items. |
insertAt( index, item ) | inserts item at index. returns new size. |
isEmpty() | returns 1 if the aggregate is empty, and 0 otherwise. |
isNonEmpty() | returns 1 if the aggregate contains some items, and 0 otherwise. |
max( [ 'Strict' ] ) | returns maximum value of items. uses a toString call per item if necessary. performs a standard non-strict comparison per item pair, unless the 'Strict' comparison option is specified. |
maxLength() | returns length of longest item. uses a toString call per item if necessary. |
mean() | same as average(). |
min( [ 'Strict' ] ) | returns minimum value of items. uses a toString call per item if necessary. performs a standard non-strict comparison per item pair, unless the 'Strict' comparison option is specified. |
minLength() | returns length of shortest item. uses a toString call per item if necessary. |
removeAt( index ) | removes indexed item. returns the item that was removed |
removeAll() | removes all items. returns instance reference. |
removeMultiple( index, length ) | removes multiple items. the length value indicates the number of items to remove. returns instance reference. |
resize( count ) | resets the number of items in the aggregate. returns instance reference. |
setAt( index, value ) | replaces indexed item and returns the prior value. If the aggregate is a map a new association is established, otherwise the indexed item must be present. If the index is one larger than the aggregate's size, the item is added at the end. |
size() | returns the number of aggregated items. |
sum() | returns sum of items. uses a toString call per item if necessary. all values must be numeric. |
standardDeviation() | returns standard deviation of items. uses a toString call per item if necessary. all values must be numeric. |
toDelimitedString( delimitingValue ) (aka join) |
prepares a delimited value string from items. uses a toString call per item. same as toString if the delimiting value is a comma. the delimiter can be the empty string ! |
toHtmlString( [ listGroupTag [, listElementTag ] ] ) | returns an HTML file segment string. the default listGroupTag is 'UL'. the default listElementTag is 'LI'. tags can include attributes. the first word of a tag is used in the end tag. uses a toHtmlString call per item. if the item does not have a toHtmlString method, then a toString method is used. |
toStem( stem ) | prepares stem collection -- stem.0 is number of items, stem.1 is first item, etc. uses a toString call per item. returns number of items -- same as stem.0 |
toString() | prepares comma separated value string from items. uses a toString call per item. |
toSystemQueue() | adds items to the external data queue. returns number of items. uses a toString call per item. |
toXmlString( [ listGroupTag [, listElementTag ] ] ) | returns an XML file segment string. the default listGroupTag is 'roo:list'. the default listElementTag is 'roo:listitem'. tags can include attributes. the first word of a tag is used in the end tag. uses a toXmlString call per item. if the item does not have a toXmlString method, then a toString method is used. returns a string of lines separated by newline characters ('0a'x) |
variance() | returns variance of items. uses a toString call per item if necessary. all values must be numeric. |
(1) lines can be separated by an isolated carriage return ('0d'x), an isolated line feed ('0a'x), or a combination of these in either order.
Observe: the various methods that start with 'add', as well as the copyAggregate and removeAll methods, return a string which is a reference to the current instance. This allows the result of the operation to be processed directly as follows:
say ^^ vector ~ add( 'abracadabra', 'shazam' ) ~ toString /* shows: abracadabra,shazam */ |
The BitVector class is excellent for storing a a condensed vector of boolean values of a fixed sizes. The extent can not exceed 4096 bits. The default extent is 128 bits. The active extent can be revised to a more convenient size by using the resize method. When more bits are required, you can make a vector of bitvectors. A substring of bits can be extracted by the getMultiple and getMultipleBytes methods. Similarly, a substring can be assigned by the setMultiple and setMultipleBytes methods. Bits can be accessed with square brackets. You can also process the bits with the LOOP .. OVER instruction.
Bits are indexed using the normal Rexx method. An index of 1 references the first bit location.
Hint: generally you will use a bit vector that is shorter than 4096 bits. In this case, don't forget to use the resize method, otherwise you will get surprises when the toString method is invoked.
allOff() | returns "1" if all bits are off, and "0" otherwise. |
allOn() | returns "1" if all bits are on, and "0" otherwise. |
and( otherBitVector ) | performs a bitwise AND of this bit vector with otherBitVector. returns instance reference. |
anyOn() | returns "1" if any bit is on, and "0" otherwise. |
count() | returns number of bits that are on. |
exclusiveOr( otherBitVector ) | performs a bitwise EXCLUSIVE-OR of this bit vector with otherBitVector. returns instance reference. |
flipAll() | flips all bits off. returns instance reference. |
flipAt( index ) | flips indexed bit on. returns the bit's new value. |
fromString( booleanString ) | prepares bits from boolean digits in booleanString -- e.g. "00101010". the number of bits that are assigned is limited by the length of the string. returns instance reference. |
getAt( index ) | gets indexed bit value -- "0" or "1" |
getMultiple( index, length ) | prepares boolean string from substring of bits -- e.g. "00101010" |
getMultipleBytes( index, length ) | prepares Rexx hexadecimal literal string from substring of bits -- e.g. '42 00 42 ...etc 'x |
initialize( [ booleanString ] ) | prepares bit vector, and optionally sets bits from boolean digits in booleanString -- e.g. "00101010" |
or( otherBitVector ) | performs a bitwise OR of this bit vector with otherBitVector. returns instance reference. |
resetAll() | resets all bits off. returns instance reference. |
resetAt( index ) | resets indexed bit. returns the bit's prior value. |
resize( newSize ) | alters the size of the bit vector. the maximum size is 1024. bits after the newSize are reset to zero. returns instance reference. |
setAll() | sets all bits off. returns instance reference. |
setAt( index [, booleanValue ] ) | sets indexed bit on. if booleanValue is specified, the bit is set to the value. returns the bit's prior value. |
setMultiple( index, booleanString ) | assigns substring of bits from boolean string -- e.g. "00101010". the number of bits that are assigned is limited by the length of the string. returns prior value boolean string. |
setMultipleBytes( index, byteString ) | assigns substring of bits from Rexx hexadecimal literal string -- e.g. '42 00 42 ...etc 'x. the number of bits that are assigned is limited by the length of the hexadecimal literal. returns prior value boolean string. |
size() | returns the current number of bits. which is 4096, or a smaller size established by the resize method. |
toByteString() | prepares Rexx hexadecimal literal string from bits -- e.g. '42 00 42 ...etc 'x. |
toString() | prepares boolean string from bits -- e.g. "00101010". |
The following shows various BitVector method uses. The quoted value in parentheses following the say keyword is the value of the expression to the right of the quoted value.
bv = ^^ bitvector say '(4096)' bv ~ size say '(8)' bv ~ resize( 8 ) ~ size say '(1)' bv ~ alloff say '(0)' bv ~ allon say '(0)' bv ~ anyon say '(0)' bv ~ count say '(1)' bv ~ flipAt( 8 ) say '(00000001)' bv ~ toString say '(0)' bv ~ alloff say '(0)' bv ~ allon say '(1)' bv ~ anyon say '(1)' bv ~ count say '(0)' bv ~ flipAt( 8 ) say '(11111111)' bv ~ flipAll ~ toString say '(0)' bv ~ alloff say '(1)' bv ~ allon say '(1)' bv ~ anyon say '(8)' bv ~ count say '(00000000)' bv ~ flipAll ~ toString say '(1)' bv ~ alloff say '(0)' bv ~ allon say '(0)' bv ~ anyon say '(0)' bv ~ count say '(11111111)' bv ~ setAll ~ toString say '(0)' bv ~ alloff say '(1)' bv ~ allon say '(1)' bv ~ anyon say '(8)' bv ~ count say '(00000000)' bv ~ resetAll ~ toString say '(0)' bv ~ setAt( 8 ) say '(1)' bv ~ getAt( 8 ) say '(1)' bv [ 8 ] -- square bracket indexing is supported say '(00000001)' bv ~ toString say '(01)' c2x( bv ~ toByteString ) say '(01)' bv ~ getMultiple( 7, 2 ) say '(01)' c2x( bv ~ getMultipleBytes( 1, 8 ) ) say '(1)' bv ~ setAt( 8 ) say '(1)' bv ~ resetAt( 8 ) bv[ 8 ] = '1' -- square bracket indexing is supported say '(1)' bv [ 8 ] -- square bracket indexing is supported say '(00000000)' bv ~ toString say '(0)' bv ~ setAt( 8 ) say '(00000000)' bv ~ resetAll ~ toString say '(00)' bv ~ setMultiple( 7, '11' ) say '(11)' bv ~ setMultiple( 7, '00' ) say '(00000000)' bv ~ setMultipleBytes( 1, '42'x ) say '(42)' c2x( bv ~ toBytestring ) say '(02)' c2x( bv ~ getMultipleBytes( 5, 4 ) ) bv1 = ^^ bitVector( '01010101' ) ~ resize( 8 ) bv2 = ^^ bitVector( '10101010' ) ~ resize( 8 ) say '(00000000)' bv1 ~ and( bv2 ) ~ tostring say '(01010101)' bv1 ~ fromString( '01010101' ) ~ toString -- reset bits say '(11111111)' bv1 ~ or( bv2 ) ~ tostring bv1 ~ fromString( '01010101' ) -- reset bits say '(11111111)' bv1 ~ exclusiveOr( bv2 ) ~ tostring say '(00000000)' bv1 ~ exclusiveOr( bv1 ) ~ tostring -- exclusiveOr self => all 0's bv1 ~ fromString( '10000010' ) say '(10000010)' bv1 ~ and( bv2 ) ~ tostring say '(10101010)' bv1 ~ or( bv2 ) ~ tostring |
The CharacterVector class is a vector of single byte values. A reduced set of the vector class methods are supported -- getAt, removeAt, removeAll, setAt, and size.
addString( value [, separatingValue ] ) | adds a Rexx value to the end of the character vector. the optional separatingValue is added to the end of the character vector, before adding the new value. the value, and the separatingValue, can be the empty string. returns instance reference. |
addWideCharacterVector( wideCharacterVector ) | adds characters from another wideCharacterVector instance. each value in the input vector is in host byte order. bytes are stored in the order -- highest first, then lowest. returns instance reference. |
addWideNetworkCharacterVector( wideCharacterVector ) | adds characters from another wideCharacterVector instance. each value in the input vector is in wide network byte order. wide network bytes are converted to wide host bytes, and then, bytes are stored in the order -- highest first, then lowest. returns instance reference. |
getAt( index ) | gets indexed character. |
initialize( [ initialValue ] ) | initializes vector with optional value. the value's toString method is invoked, if the value is an instance reference. |
insertAt( index, string ) | inserts characters in string at index. returns new size. |
insertWideAt( index, wideCharacterVectorInstance ) | inserts wide characters at index. two bytes are added to the character vector. bytes are inserted in the order -- highest first, then lowest. returns new size. |
removeAt( index ) | removes indexed character. returns the character that was removed. |
removeAll() | removes all characters. returns instance reference. |
removeMultiple( index, length ) | removes multiple characters. the length value indicates the number of characters to remove. returns instance reference. |
setAt( index, value ) | replaces indexed character(s) and returns the prior value. the size of the character vector can increase, if the index is one larger than. the current size, or if the value contains multiple characters which exceed. the size at the replaced position. |
size() | returns the number of aggregated characters. |
toString() | returns a string, which may include hexadecimal values. |
toWideCharacterVector() | exports contents to a new wideCharacterVector instance. |
toWideNetworkCharacterVector() | exports contents to a new wideCharacterVector instance, in network byte order. |
The Clipboard class is used to get text from the system clipboard, or to replace the clipboard text.
Note: some system environments do not have clipboards, so the use of this class may introduce portability difficulties.
getText() | gets clipboard text -- empty string if none is available. |
setText( text ) | assigns clipboard text. returns "1" if successful, and "0" otherwise. |
Some built-in classes use an optional comparator object to compare two items. A comparator object extends class comparator and must implement the isLess method as described below. When the comparator object is absent the Rexx less-than ( < ) operator is used instead. The Rexx less-than operator performs a numeric comparison when both items are numeric, otherwise a fixed case string comparison is performed.
This is an abstract description of the interfaces of an actual comparator class instance.
initialize() | initializes the instance |
isLess( item, item ) | compares two arguments; returns 1 when first is less, and 0 otherwise. |
Note: if either item (or both) being compared is a class instance, then it is up to the isLess method to convert the item to a comparable value. For example, the toString method of the item could be invoked to obtain a comparison value.
The console class is used to read and write characters or strings from or to the console.
emit() | sends text to destination. returns instance reference. |
hasInput() | returns 1 if input is available, and 0 otherwise. |
initialize() | initializes the instance |
println( [ line [, line, ... ] ] ) | (same as writeLine) |
readCharacters( n ) | reads specified number of characters from the console. |
readLine() | reads characters from the console until the Enter key is pressed. |
readln() | (same as readLine) |
writeCharacters( string ) | writes string to the console, without a trailing line terminator. returns number of characters that remain to be written (usually 0). |
writeLine( [ line [, line, ... ] ] ) | writes one or more lines to the console, ending each line with a line terminator. if no arguments are specified a single line terminator is written. returns number of lines that remain to be written (usually 0). |
The ContextVector class is used to analyze active method and procedure invocations. Each line contains the name of an active method or procedure, the associated source line, and a comma separated list of call arguments.
When method contexts are listed method names are preceded by the class name and a caret.
getAt( index ) | returns context information. |
initialize() | initializes the instance |
print() | prints context information to the console |
size() | returns number of contexts. |
Example of use:
cv = ^^ ContextVector do n=1 for cv ~ size say 'Execution context #'n '--' cv[ n ] end |
The DriveContext class establishes a drive as the current disk drive. When activated a DriveContext is similar to invoking a command that changes the active disk; i.e. A:
Observe: the drive context that was in effect prior to DriveContext instance creation is always restored, when the instance is removed.
A drive context has the same methods as a drive object.
initialize( [ driveLetter ] ) | prepares a drive context and sets driveLetter as the current drive, if it exists. if the driveLetter argument is absent, a context is established for the current file system drive. |
exists() | returns 1 if the drive exists, and 0 otherwise. |
getFolders() | returns a set of folder class instances. |
initialize( driveLetter ) | prepares to access drive information. |
toDetailedString() | returns the following space-separated values:. driveLetter driveType totalSpace freeSpace clusterSize activeDirectory. If disk space information is unavailable, then the totalSpace, freeSpace, and clusterSize values are all underscores. |
toString() | returns the drive name (i.e. C). |
Note: an irksome message box may be displayed when media is absent from a drive that supports mountable media -- i.e. floppy disks, CD-ROMs, etc. This message appears when either the exists, or toDetailedString methods are invoked.
The emitter class is used to write characters or strings to an arbitrary output stream. All emitter class derivatives should implement the methods listed below. This allows alternate emitters to be passed as parameters to procedures and methods. An example of a program that uses alternate emitters is qt.rooProgram.
emit() | sends text to destination. returns instance reference. |
initialize() | initializes the instance |
println( [ line [, line, ... ] ] ) | (same as writeLine) |
writeCharacters( string ) | writes string to the console, without a trailing line terminator. |
writeLine( [ line [, line, ... ] ] )() | writes one or more lines, ending each line with a line terminator. if no arguments are specified a single line terminator is written. returns number of lines that remain to be written (usually 0). |
Exception information that can be referenced by catch condition handlers
description() | prepares a printable string that describes the exception. |
initialize() | initializes the instance |
instruction() | identifies the instruction associated with the exception. |
name() | identifies the exception name. |
state() | identifies the state of the exception. |
toString() | prepares a printable string associated with the exception. this is a comma-separated combination of the above method results. in the order:. name,description,instruction,state |
An ExternalClass is a built-in class that invokes methods in an external program. In Windows system environments the program is a dynamic link library (DLL). An optional call back capability is also supported.
initialize( externalProgramName [, initializationArguments ] ) | instance initialization. loads externalProgramName, and invokes its optional 'initialize' method with the initializationArguments. |
perform( methodName, [ invocationArguments ] ) | invokes external class methodName. |
Note: the externalProgramName is automatically unloaded when all ExternalClass instance usages become inactive. The optional 'terminate' method of the external program is performed before unloading the program.
Note: the external program can call back to methods in a class that extends an ExternalClass instance. The WinList.rooProgram example, and WinList.roo class, illustrate the usage of ExternalClass with a program named WinList.dll.
The following diagram illustrates the components that are used in the WINLIST example.
![]() |
The external module can optionally provide an entry point named 'SetCallback'.
When this entry is present, its is invoked during instance initiation, with
an instanceContextLocator argument. This allows the external module to callback to the
The File class is used to obtain information about a specific file
For some of the following methods the example file name is:
c:\roo\aProgram.rooProgram |
initialize( filename ) | file to analyze. The file name can be partially qualified. It is retained as a fully qualified name at the time of initialization. |
exists() | returns 1 if the file exists, and 0 otherwise. |
getDirectoryPath() | returns the directory containing the file name. for the example file name, the directory name is: c:\roo. Note: if the file being analyzed is a directory, getDirectoryPath returns the parent directory path that contains the directory. |
getExtension() | returns the final file name segment. for the example file name, the extension is: rooProgram. |
getFullPathName() | returns the complete file system name of the file (or directory). for the example file name, the full path name is: c:\roo\aProgram.rooProgram. |
getName() | returns the file name segment that follows the directory path, and precedes the extension. for the example file name, the name is: aProgram. |
getNameAndExtension() | returns the file name and extension that follows the directory path. for the example file name, the name and extension value is: aProgram.rooProgram. |
initialize( filename ) | file to analyze. The file name can be partially qualified. It is retained as a fully qualified name at the time of initialization. |
isDirectory() | returns 1 if the filename is a directory, and 0 otherwise. |
isFile() | returns 1 if the filename is a file (not a directory), and 0 otherwise. |
isReadonly() | returns 1 if the file is NOT writeable, and 0 otherwise. |
isWriteable() | returns 1 if the file IS writeable, and 0 otherwise. |
toDetailedString() | returns the following space-separated values:. fileModificationDateAndTime dirOrSize accessability. the fileModificationDateAndTime value is formatted as YYYY/MM/DD-HH:MM:SS. the dirOrSize value is 'DIR' if the file is a directory, otherwise it is the number of characters withinin the file. accessability is 'RO' if the file is read-only, and 'RW' if the file is writeable. |
toString() | returns the file name -- same as getFullPathName(). |
The FolderContext class establishes a folder as the current folder for subsequent file. system activity. When activated a FolderContext is similar to invoking a CHDIR command.
Observe: the folder context that was in effect prior to FolderContext instance creation is always restored, when the instance is removed.
initialize( [ folderPath ] ) | prepares a folder context and sets folderPath as the current folder, if it exists. if the folderPath argument is absent, a context is established for the current file system folder. |
exists() | returns 1 if the folder exists, and 0 otherwise. |
getFiles( [ filePattern ] ) | returns a set of file class instances, one per file that matches the filePattern. The default pattern is: "*.*". |
getSubFolders() | returns a set of folderContext class instances. |
initialize( folderPath ) | prepares to access folder information. |
toDetailedString() | returns the following space-separated values:. a fileModificationDateAndTime value, formatted as YYYY/MM/DD-HH:MM:SS. |
toString() | returns the folder name (i.e. C:\ROO). |
The InLineFile class is a line-oriented encapsulation of Rexx input/output stream capabilities. When the class is initialized all lines are loaded, and the file is closed. Subsequently, the InLineFile instance can be accessed by any of the Vector class methods, that do not alter line contents.
Observe: a NOTREADY condition is signalled, if enabled, when an attempt is made to read more than the number of available lines.
initialize( [ streamName [, 'NoPromptIfAbsent' ] ] ) | loads the stream. when streamName is the empty string, or absent, the default input or output stream is used. a prompt is displayed if the file does not exist, and the 'NoPromptIfAbsent' option is not specified. |
locate( line# ) | establishes a line reading position. line# must be between 1 and the number of lines in the file. returns "1" if successful, and "0" otherwise. |
readLine() | reads a line. |
readln() | (same as readLine). |
Hint: the file is closed when all instances are no longer active. Often you can accomplish this by dropping the variable that has the file instance value. For example:
fil = ^^ InLineFile( 'yourFile' ) drop fil -- this closes the file |
The InOutLineFile class is a line-oriented encapsulation of Rexx input/output stream capabilities. The class is intended to revise an existing file. When the class is initialized all lines are loaded. Subsequently, the InOutLineFile instance can be accessed by any of the List class methods. When all instance uses are inactive lines are flushed to the external file associated with the stream, and the stream is closed.
The InOutLineFile class is intended for general file alterations; i.e. deletions and insertions. The related InLineFile and OutLineFile are more appropriate for sequential file access.
Separate line positions are maintained for reading and writing.
Observe: a NOTREADY condition is signalled, if enabled, when an attempt is made to read more than the number of available lines.
initialize( [ streamName [, 'NoPromptIfAbsent' ] ] ) | loads the stream. when streamName is the empty string, or absent, the default input or output stream is used. a prompt is displayed if the file does not exist, and the 'NoPromptIfAbsent' option is not specified. |
emit() | updates the external file associated with the stream. returns instance reference. |
initialize( [ streamName [, 'NoPromptIfAbsent' ] ] ) | loads the stream. when streamName is the empty string, or absent, the default input or output stream is used. a prompt is displayed if the file does not exist, and the 'NoPromptIfAbsent' option is not specified. |
locateToRead( lineNumber ) | establishes lineNumber as the current read position. returns "1" if successful, and "0" otherwise. |
locateToWrite( lineNumber ) | establishes lineNumber as the current write position. returns "1" if successful, and "0" otherwise. |
permitWriteAtEnd( optionSetting ) | if optionSetting is 1, changes are written when all instances conclude. if optionSetting is 0, changes are discarded when all instances conclude. by default, changes are written when all instances conclude. returns instance reference. |
readLine() | reads a line from the current read position. |
readln() | (same as readLine). |
writeLine( [ line [, line, ... ] ] ) | writes one or more lines from the current write position. when the file is written, each line is concluded by a line terminator. if no arguments are specified a single line terminator is written. returns number of lines written. no lines are written if the file is read-only. |
println( [ line [, line, ... ] ] ) | (same as writeLine) |
Hint: the file is closed when all instances are no longer active. Often you can accomplish this by dropping the variable that has the file instance value. For example:
fil = ^^ InOutLineFile( 'yourFile' ) fil ~ writeLine( '...' ) drop fil -- this writes file lines and closes the file |
The outstream class is used to read characters or strings from the default input stream (standard input).
hasInput() | returns 1 if input is available, and 0 otherwise. |
initialize() | initializes the instance |
readCharacters( n ) | reads specified number of characters. |
readLine() | reads characters until the Enter key is pressed. |
readln() | (same as readLine) |
The List class is excellent for storing an arbitrary collection of heterogeneous objects. The performance of getAt and setAt requests is worse than the corresponding vector class. Performance is better than the corresponding vector class when items are inserted or removed at the front or the middle of the list.
The list class supports all aggregate class methods.
initialize( [ item, item, ... ] ) | prepares the list instance, and optionally adds a series of items. |
The Map class is excellent for storing a keyed collection of heterogeneous items. Each item that is associated with a key can be a Rexx value or an instance reference. An optional comparator instance can be assigned to establish a custom ordering of items. When a comparator instance has not been assigned standard, non-strict, Rexx comparisons are used to establish the ordering. Thus, numeric values are in numeric order. String values are in collating order. When class instance values are encountered, their associated value is the result of their 'ToString' method. When the associated class lineage does not have a 'ToString' method, an implicit value is used which is the class name followed by the relative instance index -- i.e. SOMECLASS #3.
add( key, value ) | associates key and value. returns instance reference |
addMap( mapInstance ) | adds all associations from another map. returns instance reference. |
comparator( comparatorValue ) | if comparatorValue is "REVERSE" items are sorted in reverse collating order. if comparatorValue is "MIXED" items are sorted in case-insensitive collating order. otherwise comparatorValue is a custom comparison class instance. returns the ordered vector's instance reference. |
contains( key ) | returns 1 if the map contains key, and 0 otherwise. |
copyMap( mapInstance ) | removes all associations. adds all associations from another map. returns instance reference. |
getAt( key ) | gets item associated with key. |
getIndices() | returns a set instance that contains all of the keys in this association. this is used by the LOOP .. OVER instruction |
initialize() | prepares a map instance. |
isEmpty() | returns 1 if the map is empty, and 0 otherwise. |
isNonEmpty() | returns 1 if the map contains some keys, and 0 otherwise. |
removeAt( key ) | removes key. returns instance reference. |
removeAll() | removes all keys. returns instance reference. |
setAt( key, value ) | replaces value associated with key. returns the prior value, or the empty string if a value was not associated with key. |
size() | returns the number of map associations. |
toDelimitedString( delimitingValue ) (aka join) |
prepares a delimited value string from keys. an equal sign separates each key and value. uses a toString call per key value. same as toString if the delimiting value is a comma. the delimiter cannot be the empty string ! |
toHtmlString() | returns an HTML file segment string. the group begins with a 'DL' tag. each key is defined within a 'dt' tag. each value is defined within a 'dd' tag. uses a toHtmlString call per key value. if the item does not have a toHtmlString method, then a toString method is used. |
toHtmlTableString( [ mapTableOptions ] [ , [ mapKeyColumnHeading ] [ , mapValueColumnHeading ] ] ) | returns an HTML file table segment string. the default mapTableOptions is 'border=1'. the default mapKeyColumnHeading is 'Key'. the default mapValueColumnHeading is 'Value'. uses a toHtmlString call per value. if the value does not have a toHtmlString method, then a toString method is used. |
toStem( stem ) | prepares stem collection -- stem.0 is number of associations, stem.1.key is first key, stem.1.value is first value, etc. uses a toString call per key value. returns number of associations -- same as stem.0 |
toString() | prepares comma separated value string from associations. uses a toString call per key value. |
toSystemQueue() | adds associations as lines to the external data queue. an equal sign separates each key and value. uses a toString call per key value. returns number of associations. |
toXmlString( [ mapGroupTag ] [ , [ mapKeyTag ] [ , mapValueTag ] ] ) | returns an XML file segment string. the default mapGroupTag is 'roo:map'. the default mapKeyTag is 'roo:mapkey'. the default mapValueTag is 'roo:mapvalue'. tags can include attributes. the first word of a tag is used in the end tag. uses a toXmlString call per value. if the value does not have a toXmlString method, then a toString method is used. returns a string of lines separated by newline characters ('0a'x). |
The Math class provides various mathematic functions (sine, cosine, etc) and constants (π, e, Φ, γ)
Note: the arguments for the trigonometric methods, and associated results, are measured in radians, not degrees!
Warning: if an argument is outside the domain of a function the string 'undefined' is returned.
Note: additional mathematic functions -- Gamma(X), lnGamma(X), sinh, cosh, sinh-1, etc. -- can be found in the MathX.roo example program.
bernoulliNumber( N ) | returns the Nth Bernoulli number -- Bn( N ). Note: N must be a non-negative even number. The largest bernoulli number that is available is Bn( 60 ). |
e() | returns the natural number e 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 69996 ... (up to NUMERIC DIGITS) |
gamma() | returns Euler's constant -- γ 0.57721 56649 01532 86061 |
phi() | returns the golden ratio, phi -- Φ 1.61803 39887 49898 84820 45868 34365 63811 77203 09180 |
pi() | returns PI -- π 3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37511 ... (up to NUMERIC DIGITS) |
factorial( n ) | returns the factorial of n which must be a non-negative whole number that does not exceed 20. Note: you can use factorial.rex for larger values of n. |
naturalLogarithm( n ) (aka ln) |
returns the naturalLogarithm of n. n must be greater than 0. |
naturalPower( n ) | returns the natural number e raised to the power n. |
power( a, n ) | returns the value of a raised to the power n. If n is not a whole number, then a must be non-negative. If a is negative, and n is not a whole number, a syntax error condition is raised. If a and n are both zero, a syntax error condition is raised. |
convertDegreesToRadians( nDegrees ) | converts #degrees to the corresponding #radians. Note: the nDegrees is internally converted to the domain 0° to 360°. |
convertRadiansToDegrees( nRadians ) | converts #radians to the corresponding #degrees. Note: the nRadians is internally converted to the domain 0 to 2 π. |
sine( nRadians ) (aka sin) |
returns the sine of the angle measured as nRadians. |
cosine( nRadians ) (aka cos) |
returns the cosine of the angle measured as nRadians. |
tangent( nRadians ) (aka tan) |
returns the tangent of the angle measured as nRadians. abs( nRadians ) must be less than π / 2 |
arcSine( sineValue ) (aka arc sin) |
returns the #radians of the angle which has sine sineValue. abs( sineValue ) must be less than 1 |
arcCosine( cosineValue ) (aka arccos) |
returns the #radians of the angle which has cosine cosineValue. abs( cosineValue ) must be less than 1 |
arcTangent( tangentValue ) (aka arctan) |
returns the #radians of the angle which has tangent tangentValue. |
Here is an example that shows how to compute the sine of π/4 (45°)
math = ^^ Math say math ~ sine( ( math ~ pi ) / 4 ) |
Even better, the following example shows how to compute the value of π to 1000 decimal places.
-- the following computes PI to 1000 decimal places !!! math = ^^ math numeric digits 1000 say 4 * ( 4 * ( math ~ arctangent( 1 / 5 ) ) - math ~ arctangent( 1 / 239 ) ) |
In 1706, a mathematician named John Machin discovered that:
π / 4 = 4 * arctan( 1/5 ) - arctan( 1 / 239 )
You can click here to discover how Machin derived this incredible formula:
All classes are implicitly derived from the Object class.
created() | returns date and time of instance creation -- format: YYYYMMDD-hhmmss. |
initialize() | initializes the instance |
isInstanceOfClass( className ) | returns 1 if this instance includes the className in its class lineage, and 0 otherwise. |
lineage() | returns a series of class name lines. the first name is the outermost derived class. the last name is the lowest base class. the class Object is not listed in the result. |
toHtmlString() | (same as toString when not overridden) |
toString() | prepares a printable string associated with the instance value, if possible. |
toXmlString() | (same as toString when not overridden) |
The OrderedVector class is a vector, with the distinction that all items are ordered. Multiple items can have the same value. An optional comparator instance can be assigned to establish a custom ordering of items. When a comparator instance has not been assigned standard, non-strict, Rexx comparisons are used to establish the ordering. Thus, numeric values are in numeric order. String values are in collating order. When class instance values are encountered, their associated value is the result of their 'ToString' method. When the associated class lineage does not have a 'ToString' method, an implicit value is used which is the class name followed by the relative instance index -- i.e. SOMECLASS #3.
add( [ item [ , item [, ... ] ] ) | adds zero or more items. returns instance reference. |
comparator( comparatorValue ) | if comparatorValue is "REVERSE" items are sorted in reverse collating order. if comparatorValue is "MIXED" items are sorted in case-insensitive collating order. otherwise comparatorValue is a custom comparison class instance. returns the ordered vector's instance reference. |
contains( item ) | returns 1 if the OrderedVector contains item, and 0 otherwise. |
count( item ) | returns #items that strictly match item. |
addAggregate( aggregateInstance ) | adds multiple values from another aggregate. returns instance reference. |
addDelimitedString( string, delimitingValue ) | adds items within a delimited value string. if either string is empty nothing is added. if the delimiter is a comma, the string is treated as a comma-separated value string. if the delimiter is a newline character ('0a'x) a series of lines* is acquired. returns instance reference. |
addStem( stem ) | adds stem collection -- stem.0 is #items, stem.1 is first item, etc. returns instance reference. |
addSystemQueue() | adds items, and removes them, from the external data queue. returns instance reference. |
getAt( index ) | gets indexed item. |
initialize( [ item [ , item [, ... ] ] ) | instance creation method. initializes contents with zero or more items. |
remove( item ) | removes specific item. returns new size. |
removeall( item ) | removes all items. returns new size. |
size() | returns the number of items |
toDelimitedString( delimitingValue ) (aka join) |
prepares a delimited value string from items. uses a toString call per item. same as toString if the delimiting value is a comma. the delimiter can be the empty string ! |
toHtmlString( [ listGroupTag [, listElementTag ] ] ) | returns an HTML file segment string. the default listGroupTag is 'UL'. the default listElementTag is 'LI'. tags can include attributes. the first word of a tag is used in the end tag. uses a toHtmlString call per item. if the item does not have a toHtmlString method, then a toString method is used. |
toStem( stem ) | prepares stem collection -- stem.0 is number of items, stem.1 is first item, etc. uses a toString call per item. returns number of items -- same as stem.0. |
toString() | prepares comma separated value string from items. uses a toString call per item. |
toSystemQueue() | adds items to the external data queue. returns number of items. uses a toString call per item. |
toXmlString( [ listGroupTag [, listElementTag ] ] ) | returns an XML file segment string. the default listGroupTag is 'roo:list'. the default listElementTag is 'roo:listitem'. tags can include attributes. the first word of a tag is used in the end tag. uses a toXmlString call per item. if the item does not have a toXmlString method, then a toString method is used. returns a string of lines separated by newline characters ('0a'x). |
Observe: the union, intersection, difference, and nonIntersection methods are unavailable for an OrderedVector. These capabilities can be used by adding a orderedVector aggregate to a set instance, as shown in the first line in the example below.
Here is an example that shows the creation of an OrderedVector, which is immediately converted to a set. Then, various set computations are performed.
u = ^^ set ~ addAggregate( ^^ orderedVector( 'a', 'b', 'd', 'b' ) ) v = ^^ set( 'a', 'c', 'd', 'c' ) say 'u:' u ~ toString say 'v:' v ~ toString say 'union( u, v ) :' u ~ union( v ) ~ toString /* the union is: a,b,c,d */ say 'intersection( u, v ) :' u ~ intersection( v ) ~ toString /* the intersection is: a,d */ say 'nonIntersection( u, v ) :' u ~ nonIntersection( v ) ~ toString /* non-intersection is: b,c */ say 'difference( u - v ) :' u ~ difference( v ) ~ toString /* difference( u - v ) is: b */ say 'difference( v - u ) :' v ~ difference( u ) ~ toString /* difference( v - u ) is: c */ |
Here is an example that shows how the lines of a file can be sorted by an OrderedVector.
ovec = ^^ orderedVector ovec ~ addAggregate( ^^ InLineFile( inFileName ) ) // note: LineFile has size and getAt methods ^^ OutLineFile( outFileName ) ~ addAggregate( ovec ) |
The first line above prepares an ordered vector. The second line reads inFileName, and adds the lines to the ordered vector. The final line adds the lines, which are now sorted, to the output file outFileName. The lines are written when the scope of the output LineFile instance concludes.
The above example could be programmed in one instruction as follows
^^ OutLineFile( outFileName ) ~ addAggregate( ^^ orderedVector ~ addAggregate( ^^ InLineFile( inFileName ) ) ) |
Here is an example that shows how the lines of a file can be sorted in reverse collating order.
ovec = ^^ orderedVector ~ comparator( "REVERSE" ) ovec ~ addAggregate( ^^ InLineFile( inFileName ) ) // note: LineFile has size and getAt methods ^^ OutLineFile( outFileName ) ~ addAggregate( ovec ) |
Here is an example that shows how the lines of a file can be sorted in a custom order.
ovec = ^^ orderedVector ~ comparator( ^^ customSort ) // see customSort.roo below ovec ~ addAggregate( ^^ InLineFile( inFileName ) ) // note: LineFile has size and getAt methods ^^ OutLineFile( outFileName ) ~ addAggregate( ovec ) |
Here is an example of a customSort class:
/* customSort.roo */ isLess : method parse arg s1, s2 return length( s1 ) < length( s2 ) /* sort lines from shortest to longest */ |
The OutLineFile class is a line-oriented encapsulation of Rexx input/output stream capabilities. The class is intended to prepare a new file, or completely replace an existing file. Subsequently, the OutLineFile instance can be accessed by any of the Vector class methods. When all instance uses are inactive lines are flushed to the external file associated with the stream, and the stream is closed.
The OutLineFile class is intended for sequential writing of lines to a file, rather than deletions and insertions. The related InOutLineFile is more efficient for deletions and insertions.
initialize( [ streamName [, 'NoPromptIfExists' ] ] ) | establishes stream access. when streamName is the empty string, or absent, the default input or output stream is used. a prompt is displayed if the file exists, and the 'NoPromptIfExists' option is not specified. |
emit() | updates the external file associated with the stream. returns instance reference. |
initialize( [ streamName [, 'NoPromptIfExists' ] ] ) | establishes stream access. when streamName is the empty string, or absent, the default input or output stream is used. a prompt is displayed if the file exists, and the 'NoPromptIfExists' option is not specified. |
locate( line# ) | establishes a line writing position. line# must be between 1 and one more than the number of lines in the file. returns "1" if successful, and "0" otherwise. |
permitWriteAtEnd( optionSetting ) | if optionSetting is 1, changes are written when all instances conclude. if optionSetting is 0, changes are discarded when all instances conclude. by default, changes are written when all instances conclude. returns instance reference. |
writeLine( [ line [, line, ... ] ] ) | writes one or more lines from the current write position. when the file is written, each line is concluded by a line terminator. if no arguments are specified a single line terminator is written. returns number of lines written. no lines are written if the file is read-only. |
println( [ line [, line, ... ] ] ) | (same as writeLine). |
Hint: the file is closed when all instances are no longer active. Often you can accomplish this by dropping the variable that has the file instance value. For example:
fil = ^^ OutLineFile( 'yourFile' ) fil ~ writeLine( '...' ) drop fil -- this writes file lines and closes the file |
The outstream class is used to write characters or strings to the default output stream (standard output).
emit() | sends text to destination. returns instance reference. |
initialize() | initializes the instance |
println( [ line [, line, ... ] ] ) | (same as writeLine) |
writeCharacters( string ) | writes string to the output stream, without a trailing line terminator. returns number of characters that remain to be written (usually 0). |
writeLine( [ line [, line, ... ] ] ) | writes one or more lines to the output stream, ending each line with a line terminator. if no arguments are specified a single line terminator is written. returns number of lines that remain to be written (usually 0). |
The Pattern class establishes a regular expression pattern, and extended string search capabilities.
initialize( regularExpressionString ) | establishes a regular expression pattern. |
search( textToSearch [, ['IgnoreCase'] [, startOffset ] [, 'SegmentsAlso' ] ] ) | searches string for matches of the regularExpressionString. the pattern search uses fixed-case comparisons, unless the 'IgnoreCase' option is specified. an optional startOffset can be specified. the default startOffset is 1, which proceeds from the beginning of the string. the 'SegmentsAlso' option also obtains segments that matched part of the regular expression. by default segments that match part of the regular expression are not obtained. returns a PatternMatch built-in class instance. |
toString() | returns regularExpressionString. |
Click here to review an example of a pattern match search, that also returns segments.
The PatternMatch class provides information describing matches that occurred during a regular expression pattern search. Instances of the PatternMatch class are created by the search method of the Pattern built-in class.
offset() | returns the position within the string that was searched where the match occurred. an offset of 0 indicates that a match did not occur. |
width() | returns the width of the string that matched the regular expression. |
segments() | returns a vector of PatternMatch instances, for regular expression segments that were matched. segments that matched part of the regular expression are only available if the search() request specified the 'SegmentsAlso' option. the size of the vector is 0, if the regular expression did not have any segments. segments are defined by outermost paired parentheses within the search pattern. the expression a(.*)b has one segment .*. the expression a(.*)b([0-9]+) has two segments -- .* and [0-9]+. the expression findThis has no segments. the expression A((a.*b){3})Z has one segment (a.*b){3}. |
toString() | returns the substring within the textToSearch argument, of the associated search method of the Pattern class, that was matched. |
The following is an example of a pattern match search, that also returns segments. There are 2 segments in the pattern. These are defined within the outermost level of paired parentheses. The segments are associated with the following portions of the pattern.
pattern = ^^ pattern( "(((1-)?([0-9]{3})-){1,2})([0-9]{4})" ) say pattern ~ tostring match = pattern ~ search( "phone:207-555-1212 .", , , 'SegmentsToo' ) say 'offset' match ~ offset',width' match ~ width', text' match ~ tostring say "phone:207-363-6060 ." segments = match ~ segments loop ix over segments say 'segment' ix'. , 'offset' segments[ ix ] ~ offset , 'width' segments[ ix ] ~ width , 'text' segments[ ix ] ~ tostring end |
The Queue class is excellent for storing an arbitrary collection of heterogeneous objects. These are normally accessed at the beginning or the end. Other methods of the list class are also available; such as: isEmpty, isNonEmpty, size, setAt, and toString.
initialize() | initializes the instance |
pushFirst( item ) | adds an item to the front. returns instance reference. |
pushLast( item ) | adds an item to the end. returns instance reference. |
first() | returns the first item. |
last() | returns the last item. |
pullFirst() | retrieves, and removes the first item. |
pullLast() | retrieves, and removes, the last item. |
The Set class is a Vector, with the distinction that all items are unique, and ordered. An optional comparator instance can be assigned to establish a custom ordering of items. When a comparator instance has not been assigned standard, non-strict, Rexx comparisons are used to establish the ordering. Thus, numeric values are in numeric order. String values are in collating order. When class instance values are encountered, their associated value is the result of their 'ToString' method. When the associated class lineage does not have a 'ToString' method, an implicit value is used which is the class name followed by the relative instance index -- i.e. SOMECLASS #3.
The set class supports all aggregate class methods, plus the following methods:
comparator( comparatorClassInstance ) | if comparatorValue is "REVERSE" items are sorted in reverse collating order. otherwise comparatorValue is a custom comparison class instance. returns the set's instance reference. |
contains( item ) | returns 1 if the set contains item, and 0 otherwise. |
difference( otherSet ) | returns instance that is a set difference; a set instance minus another set instance. |
intersection( otherSet ) | returns instance that is the intersection of a set instance with another set instance. |
initialize( [ item, item, ... ] ) | prepares the set instance, and optionally adds a series of items. |
nonIntersection( otherSet ) | returns instance that is the non-intersection of a set instance with another set instance. the non-intersection is the union of two sets minus their intersection. |
union( otherSet ) | returns instance that is the union of a set instance with another set instance. |
Observe: the union, intersection, difference, and nonIntersection methods compare one set instance versus another set instance, and return a new set class instance. If otherSet value is not a set instance, an OBJECTION condition is optionally raised. If the OBJECTION condition is not actively being trapped, the new instance that is returned will be empty.
Here is an example of the use of two sets.
u = ^^ set( 'a', 'b', 'd' ) v = ^^ set( 'a', 'c', 'd' ) say 'u:' u ~ toString say 'v:' v ~ toString say 'union( u, v ) :' u ~ union( v ) ~ toString /* the union is: a,b,c,d */ say 'intersection( u, v ) :' u ~ intersection( v ) ~ toString /* the intersection is: a,d */ say 'nonIntersection( u, v ) :' u ~ nonIntersection( v ) ~ toString /* non-intersection is: b,c */ say 'difference( u - v ) :' u ~ difference( v ) ~ toString /* difference( u - v ) is: b */ say 'difference( v - u ) :' v ~ difference( u ) ~ toString /* difference( v - u ) is: c */ |
Here is an example that shows how the set can be sorted in reverse collating order.
say ^^ set ~ comparator( "REVERSE" ) ~ addDelimitedString( 'a^b^c', '^' ) ~ toString /* shows: c,b,a */ |
Here is an example that shows how a set can be sorted in a custom order. The customSort class is defined below.
say ^^ set ~ comparator( ^^ customSort ) ~ addDelimitedString( 'a^bbb^cc', '^' ) ~ toString /* shows: a,cc,bbb */ |
Here is an example of a customSort class:
/* customSort.roo */ isLess : method parse arg s1, s2 return length( s1 ) < length( s2 ) /* sort lines from shortest to longest */ |
The Socket class provides TCP/IP socket capabilities. The class can be used for UDP datagram clients or servers, or TCP clients.
Note: the Socket class cannot be used to implement TCP servers.
bind( port ) | activates socket as a UDP server for the specified port. returns: instance reference. |
close() | deactivates the TCP/IP session. returns empty string. |
convert( hexlit, conversionType ) | converts a 2 or 4 byte hexadecimal literal to or from network byte order. conversionType is either ToNetwork or FromNetwork (only the first letter is significant). The width of hexlit MUST be either 2 or 4. Warning: REXX numeric values that are converted to characters are normally in network byte order ! So the results of D2C( 1432, 2 ) or D2C( 14321432, 4 ) are both in network byte order. |
getErrorCode() | gets error code associated with last request |
getHostIp( [ hostName ] ) | returns the IP address of the current host, or the host associated with hostName. |
getHostName( [ ipAddress ] ) | returns the name of the current host, or the host associated with ipAddress. |
hostInformation() | returns host information: format: ipAddress port type hostname type is either: TCP or UDP |
initialize( type [ , ipAddress, port ] ) | initializes a TCP/IP session for subsequent send and receive requests. type is one of: TCP or UDP. ipAddress is an internet IP address; such as, 216.239.41.99, or www.google.com. port is the number of the server's port. The ipAddress and port arguments should be unspecified for a UDP client. Initialization will not respond for a long time if the server is not accepting requests. |
receive( length ) | receives a response from the server. The length of the response may be less than the requested length. A receive request may not respond for a long time if the other address is not sending data. |
receiveFrom( length ) | receives a datagram response from another address. The length of the response may be less than the requested length. A receiveFrom request must be preceded by a bind request, if the program is acting as a server. A receiveFrom request may not respond for a long time if the other address is not sending data. Hint: the hostInformation method can be used to determine the address that sent the data. See the udpServer.rooProgram example. |
send( msg ) | sends a message to the server returns: number of bytes sent. The number of bytes sent may be less than the length of msg. |
sendTo( ipAddress, port, msg ) | sends a message to the server, as a UDP datagram ipAddress is an internet IP address; such as, 216.239.41.99, or www.google.com. port is the number of the server's port. returns: number of bytes sent. The number of bytes sent may be less than the length of msg. Note: after a receiveFrom request, a sendTo request will reply to the address that sent the message of the receiveFrom request. |
The Stack class is excellent for storing an arbitrary collection of heterogeneous objects. These are normally accessed at the beginning or the end. Other methods of the vector class are also available; such as: isEmpty, isNonEmpty, setAt, size, and toString.
initialize() | initializes the instance |
push( item ) | adds an item to the end. returns an instance reference. |
pull() aka pop | gets, and removes, last item pushed. |
top() | gets last item pushed. |
stk = ^^ stack( 'open sesame', 'abracadabra', 'shazam' ) do while stk ~ isNonEmpty say stk ~ pull end |
The System class is used to access the system name, and other system information.
getDrives() | returns a set of drive class instances. |
initialize() | initializes the instance |
toString() | returns the system name (i.e. FAST_PC). |
The SystemPropertyMap class is used to reference and revise system properties (aka environment variables).
The SystemPropertyMap class has the same methods as the map class. The following methods have additional considerations.
add( key, value ) | sets environment variable key to value. returns instance reference. |
initialize() | initializes the instance |
removeAt( key ) | removes environment variable key. returns instance reference. |
setAt( key, value ) | replaces environment variable key with the new value. returns the prior value, or the empty string if a value was not associated with key. |
The following shows how all environment variables can be displayed.
props = ^^ systemPropertyMap loop ix over props say ix props[ ix ] end |
You can prepare an HTML table containing all system properties as follows.
say ^^ systemPropertyMap ~ ToHtmlTableString |
Observe: the addMap and copyMap methods are supported, but have no effect when applied to a SystemPropertyMap instance. This avoids accidental, undesired revisions to system properties.
The Table class is a list of vectors. A set of column headings is defined when the table is constructed. Each list element is called a row. Each of the vectors in a row has a fixed number of items, which are called column values. The number of items in a row is the same as the number of column headings. Item values are Rexx values or instances of other objects. References to rows and columns are indexed. A request to 'getAt( 1, 1 )' retrieves the first column value in the first row.
The following diagram may help you understand the nature of a table.
![]() |
initialize( heading1 [ , heading2, ... ] ) | defines column heading names, and implicitly the number of columns per row. at least one heading name is required. |
addAggregate( aggregateInstance ) | adds row * from aggregate. returns instance reference. |
addDelimitedString( string, delimitingValue ) | adds a row *. each column value is a delimited value within string. if either string is empty nothing is added. if the delimiter is a comma, the string is treated as a comma-separated value string. if the delimiter is a newline character ('0a'x) a series of lines* is acquired. returns instance reference. |
addDelimitedStringAggregate( aggregate, delimitingValue ) | adds rows from aggregate. each element of the aggregate is a delimited string of column values *. each column value is a delimited value within the aggregate item string. if either string is empty nothing is added. if the delimiter is a comma, the string is treated as a comma-separated value string. if the delimiter is a newline character ('0a'x) a series of lines* is acquired. returns instance reference. |
addStem( stem ) | adds stem collection * -- stem.0 is #items, stem.1 is first item, etc. returns instance reference. |
addSystemQueue() | adds a row * of items, and removes them, from the external data queue. returns instance reference. |
columnContains( column, value [ , 'IgnoreCase' ] ) | returns '1' if column contains value, and '0' otherwise. a fixed case comparison is performed unless the 'IgnoreCase' option is specified. |
getAt( row ) | gets 'row' values -- a vector of values. |
getColumn( column ) | gets 'column' -- a vector of values. |
getHeading( index ) | returns indexed column heading. |
getHeadings() | returns a vector of column headings. |
getValue( row, column ) | gets a value. |
initialize( heading1 [ , heading2, ... ] ) | defines column heading names, and implicitly the number of columns per row. at least one heading name is required. |
insertAt( index, aggregate ) | inserts aggregate at index. returns new size. |
isEmpty() | returns 1 if the table is empty, and 0 otherwise. |
isNonEmpty() | returns 1 if the table contains some items, and 0 otherwise. |
removeAt( row [, length ] ) | removes one or more row(s). the optional length value indicates the number of rows to remove. returns vector of values in removed row. |
removeAll() | removes all rows. returns instance reference. |
resize( newSize ) | resets the number of rows. The newSize must not exceed the current number of rows. returns instance reference. |
rowContains( row, value [ , 'IgnoreCase' ] ) | returns '1' if row contains value, and '0' otherwise. a fixed case comparison is performed unless the 'IgnoreCase' option is specified. |
setAt( row, aggregate [ , 'KeepRemainingValues' ] ) | sets values in 'row' from an aggregate. If the KeepRemainingValues option is not specified, additional values are reset to the empty string. returns instance reference. |
setColumn( column, aggregate [ , 'KeepRemainingValues' ] ) | sets values in 'column' from an aggregate. If the KeepRemainingValues option is not specified, additional values are reset to the empty string. returns instance reference. |
setHeading( index, newCaption ) | alters indexed heading caption. the index must be between one and the width of the table, with the following exception. When there are no rows, the index can be one more than the table width. returns prior heading value. |
setHeadings( headingAggregate ) | sets headings from an aggregate of column headings. the number of headings is not altered by this method, with the following exception. When there are no rows, the number of headings is established by this method. returns instance reference. |
setValue( row, column, value ) | revises a value. returns prior value. |
size() | returns number of rows. |
toDelimitedString( delimitingValue ) (aka join) |
prepares a delimited value string from items. uses a toString call per row/column value. same as toString if the delimiting value is a comma. the delimiter can be the empty string ! |
toHtmlString( [ tableTagOptions ] ) | prepares HTML table segment. if tableTagOptions is absent, the default table tag options value is: "border=1". uses a toHtmlString call per value. if the value does not have a toHtmlString method, then a toString method is used. |
toStem( stem ) | prepares stem collection. stem.0 is number of values, stem.1.0 is number of values in first row, stem.1.1 is value in first row and first column, etc. uses a toString call per column value. returns number of rows -- same as stem.0. |
toString() | prepares a series of lines, one per row. each line is a comma separated value string. uses a toString call per value. |
toSystemQueue() | adds rows to the external data queue. uses a toString call per row. returns number of rows. |
toXmlString( [ tableTag ] [, [ tableHeadingsTag ] [, [ tableHeadingTag ] [ , rowTag ] ] ] ] ) | prepares XML file section. the default tableTag is: roo:table. the default tableHeadingsTag is: roo:tableHeadings. the default tableHeadingTag: is roo:tableHeading. the default rowTag is: roo:tableRow. uses a toXmlString call per value. if the value does not have a toXmlString method, then a toString method is used. |
width() | returns the number of columns. which is the number of headings specified for the table class construction request. |
(*) During an add operation, if there are fewer items than the column width, empty strings are added to the other columns. If there are more items in the aggregate, an OBJECTION condition is raised if it is enabled. Otherwise, the extraneous values are ignored.
The Tree class is an arbitrary hierarchical object element. It holds three items. A content item is the value associated with this hierarchical element. A child item locates an element that is subordinate to this element. A successor item locates an element that is a subsequent peer of this element.
The xmlTree program, and it's supporting class, is an excellent example of how the Tree class can be used to process XML information.
getContent() | returns the content associated with this element. |
getChild() | returns the child associated with this element. |
getSuccessor() | returns the successor associated with this element. |
hasChild() | returns '1' if a child is associated with this element, and '0' otherwise. |
hasContent() | returns '1' if content is associated with this element, and '0' otherwise. |
hasSuccessor() | returns '1' if a successor is associated with this element, and '0' otherwise. |
initialize( [ content ] [ , [ child ] [ , successor ] ] ) | initializes this element. |
setContent() | alters the content associated with this element. returns the prior content associated with this element. |
setChild() | alters the child associated with this element. returns the prior child associated with this element. |
setSuccessor() | alters the successor associated with this element. returns the prior successor associated with this element. |
toHtmlString( [ segmentTag ] [ , [ nodeTag ] [ , childTag ] ]) | returns an HTML file segment string. the default segmentTag is 'UL'. the default nodeTag is 'P'. the default childTag is 'LI'. tags can include attributes. the first word of a tag is used in the end tag. uses a toHtmlString call per item. if the item does not have a toHtmlString method, then a toString method is used. |
toString() | prepares comma separated value string from associations. uses a toString call per key value. |
toXmlString( [ segmentTag ] [ , [ nodeTag ] [ , childTag ] ] ) | returns an XML file segment string. the default segmentTag is 'roo:tree'. the default nodeTag is 'roo:treeNode'. the default childTag is 'roo:treeChild'. tags can include attributes. the first word of a tag is used in the end tag. uses a toXmlString call per value. if the value does not have a toXmlString method, then a toString method is used. returns a string of lines separated by newline characters ('0a'x). |
The Vector class is excellent for storing an arbitrary collection of heterogeneous objects. The performance of getAt and setAt requests is better than the corresponding list class. Performance is worse than the corresponding list class when items are inserted or removed at the front or the middle of the list.
The vector class supports all aggregate class methods.
initialize( [ item, item, ... ] ) | prepares the vector instance, and optionally adds a series of items. |
The WideCharacterVector class is a vector of two byte hexadecimal literals, in host byte order. It is particularly designed to be a vector of Unicode-16 character values. A reduced set of the vector class methods are supported -- getAt, removeAt, removeAll, setAt, and size.
addString( value [, separatingValue ] ) | adds a Rexx value to the end of the character vector. the optional separatingValue is added to the end of the character vector, before adding the new value. the value, and the separatingValue, are both treated as narrow character strings; both strings are widened. the value, and the separatingValue, can be the empty string. returns instance reference. |
addWideCharacterVector( wideCharacterVector ) | prepares items from another wideCharacterVector instance. each value in the input vector is in host byte order. returns instance reference. |
addWideNetworkCharacterVector( wideCharacterVector ) | prepares items from another wideCharacterVector instance. each value in the input vector is in network byte order. returns instance reference. |
getAt( index ) | gets indexed item. |
initialize() | initializes the instance |
insertAt( index, string ) | inserts characters in string at index. returns new size. |
insertWideAt( index, wideCharacterVectorInstance ) | inserts wide characters at index. returns new size. |
removeAt( index ) | removes indexed item. returns the item that was removed. |
removeAll() | removes all items. returns instance reference. |
removeMultiple( index, length ) | removes multiple items. the length value indicates the number of items to remove. returns instance reference. |
setAt( index, value ) | replaces indexed item and returns the prior value. the value must be one or two bytes long. if the value is one byte long, it is widened to two bytes. if the value is two bytes long, it is treated as a wide character. if the index is one larger than the aggregate's size, the item is added at the end. |
size() | returns the number of aggregated items. |
toNarrowString() | prepares a string that is as long as the vector size. only the lowest byte in each item value is written to the output string. information is lost if the highest byte of an item was non-zero. |
toString() | prepares a string that is twice as long as the vector size. bytes are stored in network byte order -- highest first, then lowest. |
toWideNetworkCharacterVector() | exports contents to a new characterVector instance, in network byte order. |