Table 5.1. ooRexx Object Class
Object | |
new | |
= \= == \== <> <> || '' (abuttal) ' ' (blank) class copy defaultName hashCode hasMethod identityHash init instanceMethod instanceMethods isA |
isinstanceOf objectName objectName= request run send sendWith setMethod start startWith string unsetMethod |
Note
>>-new---------------------------------------------------------><
>>-comparison_operator(argument)-------------------------------><
1
(true) or 0
(false), the result of performing a specified comparison operation.
1
(true), otherwise 0
(false) is returned. Subclasses may override this method to define equality using different criteria. For example, the String class determines equality based on the value of the string data.
Note
>>-concatenation_operator(argument)----------------------------><
>>-class-------------------------------------------------------><
>>-copy--------------------------------------------------------><
Example 5.1. Object class - copy method
myarray=.array~of("N","S","E","W") /* Copies array myarray to array directions */ directions=myarray~copy
Note
>>-defaultName-------------------------------------------------><
>>-hashCode---------------------------------------------------><
>>-hasMethod(methodname)---------------------------------------><
1
(true) if the receiver object has a method named methodname (translated to uppercase). Otherwise, it returns 0
(false).
Note
>>-identityHash------------------------------------------------><
>>-init--------------------------------------------------------><
>>-instanceMethod(methodname)----------------------------------><
>>-instanceMethods(class)----------------------------------><
>>-isA(class)--------------------------------------------------><
Note
>>-isInstanceOf(class)-----------------------------------------><
Example 5.2. Object class - isInstanceOf method
"abc"~isInstanceOf(.string) -> 1 "abc"~isInstanceOf(.object) -> 1 "abc"~isInstanceOf(.mutablebuffer) -> 0
>>-objectName--------------------------------------------------><
>>-objectName=(newname)----------------------------------------><
Example 5.3. Object class - objectName= method
points=.array~of("N","S","E","W") say points~objectName /* (no change yet) Says: "an Array" */ points~objectName=("compass") /* Changes obj name POINTS to "compass"*/ say points~objectName /* Shows new obj name. Says: "compass" */ say points~defaultName /* Default is still available. */ /* Says "an Array" */ say points /* Says string representation of */ /* points "compass" */ say points[3] /* Says: "E" Points is still an array */ /* of 4 items */
>>-request(classid)--------------------------------------------><
make
with the string classid appended (converted to uppercase). For example, a request("string")
message causes a makeString message to be sent. If the object does not have the required conversion method, request returns the Nil object.
>>-run(method-+-------------------------------+-)-------------->< | +---------------+ | | V | | +-,Individual---+-----------+-+-+ | +-,argument-+ | +-,Array,argument---------------+
+---------------+ V | >>-send(messagename---+-----------+-+-)----------------------->< +-,argument-+
Example 5.4. Object class - send method
world=.WorldObject~new -- the following 3 calls are equivalent msg1=world~hello("Fred") msg2=world~send("HELLO", "Fred") msg3=.message~new(world,"HELLO", "i", "Fred")~~send say msg1 /* Produces Hello Fred 21:04:25.065000 */ /* for example */ say msg2 /* Produces Hello Fred 21:04:25.081000 */ /* for example */ say msg3~result /* Produces Hello Fred 21:04:25.101000 */ /* for example */ ::class 'WorldObject' public ::method hello use arg name return "Hello" name time('L')
>>-sendWith(messagename,arguments)--------------------------------><
Example 5.5. Object class - sendWith method
world=.WorldObject~new // the following 3 calls are equivalent msg1=world~hello("Fred") msg2=world~sendWith("HELLO", .array~of("Fred")) msg3=.message~new(world,"HELLO", "A", .array~of("Fred"))~~send say msg1~result /* Produces Hello Fred 21:04:25.065000 */ /* for example */ say msg2~result /* Produces Hello Fred 21:04:25.081000 */ /* for example */ say msg3~result /* Produces Hello Fred 21:04:25.101000 */ /* for example */ ::class 'WorldObject' public ::method hello use arg name return "Hello" name time('L')
>>-setMethod(methodname-+----------------------+--)----------------->< | +-,"FLOAT"-+ | +-,method-+----------+-+ +--,scope--+
+---------------+ V | >>-start(messagename---+-----------+-+-)----------------------->< +-,argument-+
Example 5.6. Object class - start method
world=.WorldObject~new msg1=world~start("HELLO") /* same as next line */ msg2=.message~new(world,"HELLO")~~start /* same as previous line */ say msg1~result /* Produces Hello world 21:04:25.065000 */ /* for example */ say msg2~result /* Produces Hello world 21:04:25.081000 */ /* for example */ ::class 'WorldObject' public ::method hello return "Hello world" time('L')
>>-startWith(messagename,arguments)--------------------------------><
Example 5.7. Object class - startWith method
world=.WorldObject~new msg1=world~startWith("HELLO", .array~of("Fred") /* same as next line */ msg2=.message~new(world,"HELLO", 'i', .array~of("Fred"))~~start /* same as previous line */ say msg1~result /* Produces Hello Fred 21:04:25.065000 */ /* for example */ say msg2~result /* Produces Hello Fred 21:04:25.081000 */ /* for example */ ::class 'WorldObject' public ::method hello use arg name return "Hello" name time('L')
>>-string------------------------------------------------------><
>>-unsetMethod(methodname)-------------------------------------><
Table 5.2. ooRexx Class Class
Object | |
↓ | |
Class | |
| |
= \= == \== <> >< activate baseClass defaultName define delete enhanced id inherit isSubclassOf metaClass |
method methods mixinClass new queryMixinClass subClass subClasses superClass superClasses inInherit |
>>-activate----------------------------------------------------><
>>-baseClass---------------------------------------------------><
>>-defaultName-------------------------------------------------><
The id class
Example 5.8. Class class - defaultName method
say .array~defaultName /* Displays "The Array class" */ say .account~defaultName /* Displays "The ACCOUNT class" */ say .savings~defaultName /* Displays "The Savings class" */ ::class account /* Name is all upper case */ ::class "Savings" /* String name is mixed case */
>>-define(methodname-+---------+-)----------------------------->< +-,method-+
Example 5.9. Class class - define method
bank_account=.object~subclass("Account") bank_account~define("TYPE",'return "a bank account"')
>>-delete(methodname)------------------------------------------><
Example 5.10. Class class - delete method
myclass=.object~subclass("Myclass") /* After creating a class */ myclass~define("TYPE",'return "my class"') /* and defining a method */ myclass~delete("TYPE") /* this deletes the method */
>>-enhanced(methods-+---------------+-)------------------------>< | +-----------+ | | V | | +---,argument-+-+
Example 5.11. Class class - enhanced method
/* Set up rclass with class method or methods you want in your */ /* remote class */ rclassmeths = .directory~new rclassmeths["DISPATCH"]=d_source /* d_source must have code for a */ /* DISPATCH method. */ /* The following sends init("Remote Class") to a new instance */ rclass=.class~enhanced(rclassmeths,"Remote Class")
>>-id----------------------------------------------------------><
Example 5.12. Class class - id method
myobject=.object~subClass("my object") /* Creates a subclass */ say myobject~id /* Produces: "my object" */
>>-inherit(classobj-+-----------+-)---------------------------->< +-,classpos-+
>>-isSubclassOf(class)-------------------------------------><
Example 5.14. Class class - isSubclassOf method
.String~isSubclassOf(.object) -> 1 .String~isSubclassOf(.mutablebuffer) -> 0
>>-metaClass---------------------------------------------------><
>>-method(methodname)------------------------------------------><
Example 5.15. Class class - method method
/* Create and retrieve the method definition of a class */ myclass=.object~subClass("My class") /* Create a class */ mymethod=.method~new(" ","Say arg(1)") /* Create a method object */ myclass~define("ECHO",mymethod) /* Define it in the class */ method_source = myclass~method("ECHO")~source /* Extract it */ say method_source /* Says "an Array" */ say method_source[1] /* Shows the method source code */
>>-methods-+----------------+---------------------------------->< +-(class_object)-+
Note
Example 5.16. Class class - methods method
objsupp=.object~methods do while objsupp~available say objsupp~index -- displays all instance method objsupp~next -- names of the Object class end
>>-mixinClass(classid-+-------------------------+-)------------>< +-,metaclass-+----------+-+ +-,methods-+
Example 5.17. Class class - mixinClass method
buyable=.object~mixinClass("Buyable") /* New subclass is buyable */ /* Superclass is Object class */
>>-new-+---------------+--------------------------------------->< | +-,---+ | | V | | +-(----arg-+--)-+
Example 5.18. Class class - new method
/* new method example */ a = .account~new /* -> Object variable balance=0 */ y = .account~new(340.78) /* -> Object variable balance=340.78 */ /* plus free toaster oven */ ::class account subclass object ::method init /* Report time each account created */ /* plus free toaster when more than $100 */ Expose balance Arg opening_balance Say "Creating" self~objectName "at time" time() If datatype(opening_balance, "N") then balance = opening_balance else balance = 0 If balance > 100 then Say " You win a free toaster oven"
>>-queryMixinClass---------------------------------------------><
1
(true) if the class is a mixin class, or 0
(false).
>>-subclass(classid-+-------------------------+-)-------------->< +-,metaclass-+----------+-+ +-,methods-+
Example 5.19. Class class - subclass method
room=.object~subclass("Room") /* Superclass is .object */ /* Subclass is room */ /* Subclass identity is Room */
>>-subclasses--------------------------------------------------><
>>-superClass------------------------------------------------><
Example 5.20. Class class - superClass method
say .object~superclass -- displays "The NIL object" say .class~superclass -- displays "The Object class" say .set~superclass -- displays "The Table class"
>>-superClasses------------------------------------------------><
Example 5.21. Class class - superClasses method
z=.class~superClasses /* To obtain the information this returns, you could use: */ do i over z say i end
>>-uninherit(classobj)-----------------------------------------><
Note
Example 5.22. Class class - uninherut method
location=.object~mixinClass("Location") room=.object~subclass("Room")~~inherit(location) /* Creates subclass */ /* and specifies inheritance */ room~uninherit(location)
Table 5.3. ooRexx String Class
Object | ||
↓ | ||
String | ||
+ Comparable | ||
new cr nl null tab | ||
+ - * ** / // % \ = \= <> >< == \== > >= \> < <= \< >> >>= << <<= \<< \>> & && | || '' (abuttal) ' ' (blank) abbrev abs b2x bitAnd bitOr bitXor c2d c2x caselessAbbrev caselessChangeStr caselessCompare caselessCompareTo caselessCountStr caselessEquals caselessLastPos caselessMatch caselessMatchChar caselessPos caselessWordPos ceiling |
center/centre changeStr compare compareTo copies countStr d2c d2x dataType decodeBase64 delStr delWord encodeBase64 equals floor format hashCode insert lastPos left length lower makeArray makeString match matchChar max min |
overlay pos replaceAt reverse right round sign space strip subChar subStr subWord subWords translate trunc upper verify word wordIndex wordLength wordPos words x2b x2c x2d |
Note
compareTo |
>>-new(stringvalue)--------------------------------------------><
>>-nl----------------------------------------------------------><
>>-cr----------------------------------------------------------><
>>-null--------------------------------------------------------><
>>-tab---------------------------------------------------------><
>>-arithmetic_operator(argument)-------------------------------><
Note
Example 5.23. String class - arithmetic methods
5+5 -> 10 8-5 -> 3 5*2 -> 10 6/2 -> 3 9//4 -> 1 9%4 -> 2 2**3 -> 8 +5 -> 5 /* Prefix + */ -5 -> -5 /* Prefix - */
>>-comparison_operator(argument)-------------------------------><
1
(true) or 0
(false), the result of performing the specified comparison operation. The receiver object and the argument are the terms compared. Both must be string objects. If argument is not a string object, it is converted to its string representation for the comparison. The one exception is when argument is the Nil object for the ==, \==, =, \=, ><, and <> operators. A string object will never compare equal to the Nil object, even when the string matches the string value of the Nil object ("The NIL object"). As a result, == will always return 0 (false) when compared to the Nil object and \== will always return 1 (true). All of the relational comparisions (for example, <, >, <=, etc.) will always return .false when compared to the Nil object.
Example 5.24. String class - comparison methods
5=5 -> 1 /* equal */ 42\=41 -> 1 /* All of these are */ 42><41 -> 1 /* "not equal" */ 42<>41 -> 1 13>12 -> 1 /* Variations of */ 12<13 -> 1 /* less than and */ 13>=12 -> 1 /* greater than */ 12\<13 -> 0 12<=13 -> 1 12\>13 -> 1
==
and \==
operators check whether two strings match exactly. The two strings must be identical (character by character) and of the same length to be considered strictly equal.
>>
or <<
carry out a simple character-by-character comparison. There is no padding of either of the strings being compared. The comparison of the two strings is from left to right. If one string is shorter than and a leading substring of another, then it is smaller than (less than) the other. The strict comparison operators do not attempt to perform a numeric comparison on the two operands.
Example 5.25. String class - comparison methods
"space"=="space" -> 1 /* Strictly equal */ "space"\==" space" -> 1 /* Strictly not equal */ "space">>" space" -> 1 /* Variations of */ " space"<<"space" -> 1 /* strictly greater */ "space">>=" space" -> 1 /* than and less than */ "space"\<<" space" -> 1 " space"<<="space" -> 1 " space"\>>"space" -> 1
>>-logical_operator(argument)----------------------------------><
Note
>>-concatenation_operator(argument)----------------------------><
Example 5.27. String class - concatenation methods
f = "abc" f"def" -> "abcdef" f || "def" -> "abcdef" f "def" -> "abc def"
>>-abbrev(info-+---------+-)----------------------------------->< +-,length-+
1
if info is equal to the leading characters of the receiving string and the length of info is not less than length. Returns 0
if either of these conditions is not met.
Example 5.28. String class - abbrev method
"Print"~abbrev("Pri") -> 1 "PRINT"~abbrev("Pri") -> 0 "PRINT"~abbrev("PRI",4) -> 0 "PRINT"~abbrev("PRY") -> 0 "PRINT"~abbrev("") -> 1 "PRINT"~abbrev("",1) -> 0
Note
0
, or the default, is used. This allows a default keyword to be selected automatically if desired.
Example 5.29. String class - abbrev method
say "Enter option:"; pull option . select /* keyword1 is to be the default */ when "keyword1"~abbrev(option) then ... when "keyword2"~abbrev(option) then ... ... otherwise nop; end;
>>-abs---------------------------------------------------------><
>>-b2x---------------------------------------------------------><
0
or 1
) digits. It can be of any length. It can optionally include whitespace characters (at 4-digit boundaries only, not leading or trailing). These are to improve readability and are ignored.
A
-F
and does not include whitespace.
0
digits are added on the left before the conversion to make a total that is a multiple of four.
Example 5.31. String class - b2x method
"11000011"~b2x -> "C3" "10111"~b2x -> "17" "101"~b2x -> "5" "1 1111 0000"~b2x -> "1F0"
>>-bitAnd-+--------------------+------------------------------->< +-(string-+------+-)-+ +-,pad-+
Example 5.33. String class - bitand method
"12"x~bitAnd -> "12"x "73"x~bitAnd("27"x) -> "23"x "13"x~bitAnd("5555"x) -> "1155"x "13"x~bitAnd("5555"x,"74"x) -> "1154"x "pQrS"~bitAnd(,"DF"x) -> "PQRS" /* ASCII */
>>-bitOr-+--------------------+-------------------------------->< +-(string-+------+-)-+ +-,pad-+
Example 5.34. String class - bitor method
"12"x~bitOr -> "12"x "15"x~bitOr("24"x) -> "35"x "15"x~bitOr("2456"x) -> "3556"x "15"x~bitOr("2456"x,"F0"x) -> "35F6"x "1111"x~bitOr(,"4D"x) -> "5D5D"x "pQrS"~bitOr(,"20"x) -> "pqrs" /* ASCII */
>>-bitXor-+--------------------+------------------------------->< +-(string-+------+-)-+ +-,pad-+
Example 5.35. String class - bitxor method
"12"x~bitXor -> "12"x "12"x~bitXor("22"x) -> "30"x "1211"x~bitXor("22"x) -> "3011"x "1111"x~bitXor("444444"x) -> "555544"x "1111"x~bitXor("444444"x,"40"x) -> "555504"x "1111"x~bitXor(,"4D"x) -> "5C5C"x "C711"x~bitXor("222222"x," ") -> "E53302"x /* ASCII */
>>-c2d-+-----+------------------------------------------------->< +-(n)-+
0
.
Example 5.36. String class - c2d method
"09"X~c2d -> 9 "81"X~c2d -> 129 "FF81"X~c2d -> 65409 ""~c2d -> 0 "a"~c2d -> 97 /* ASCII */
receiving_string~right(n,'00'x)
had been processed. If n is 0
, c2d always returns 0
.
Example 5.37. String class - c2d method
"81"X~c2d(1) -> -127 "81"X~c2d(2) -> 129 "FF81"X~c2d(2) -> -127 "FF81"X~c2d(1) -> -127 "FF7F"X~c2d(1) -> 127 "F081"X~c2d(2) -> -3967 "F081"X~c2d(1) -> -127 "0031"X~c2d(0) -> 0
>>-c2x---------------------------------------------------------><
1
returns 31
because "31"X is the ASCII representation of 1
.
A
-F
and does not include whitespace. The receiving string can be of any length. If the receiving string is null, c2x returns a null string.
Example 5.38. String class - c2x method
"0123"X~c2x -> "0123" /* "30313233"X in ASCII */ "ZD8"~c2x -> "5A4438" /* "354134343338"X in ASCII */
>>-caselessAbbrev(info-+---------+-)----------------------------------->< +-,length-+
1
if info is equal to the leading characters of the receiving string and the length of info is not less than length. Returns 0
if either of these conditions is not met. The characters are tested using a caseless comparison.
Example 5.39. String class - caselessAbbrev method
"Print"~caselessAbbrev("Pri") -> 1 "PRINT"~caselessAbbrev("Pri") -> 1 "PRINT"~caselessAbbrev("PRI",4) -> 0 "PRINT"~caselessAbbrev("PRY") -> 0 "PRINT"~caselessAbbrev("") -> 1 "PRINT"~caselessAbbrev("",1) -> 0
Note
0
, or the default, is used. This allows a default keyword to be selected automatically if desired.
Example 5.40. String class - caselessAbbrev method
say "Enter option:"; parse pull option . select /* keyword1 is to be the default */ when "keyword1"~caselessAbbrev(option) then ... when "keyword2"~caselessAbbrev(option) then ... ... otherwise nop; end;
>>-caselessChangeStr(needle,newneedle--+--------+--)--------------------------------->< +-,count-+
Example 5.41. String class - caselessChangeStr method
"AbaAbb"~caselessChangeStr("A","") -> "bbb" AbaBabAB~changeStr("ab","xy") -> "xyxyxyxy" AbaBabAB~changeStr("ab","xy",1) -> "xyaBabAB"
>>-caselessCompare(string-+------+-)----------------------------------->< +-,pad-+
0
if the argument string is identical to the receiving string using a caseless comparison. Otherwise, returns the position of the first character that does not match. The shorter string is padded on the right with pad if necessary. The default pad character is a blank.
Example 5.42. String class - caselessCompare method
"abc"~caselessCompare("ABC") -> 0 "abc"~caselessCompare("Ak") -> 2 "ab "~caselessCompare("AB") -> 0 "AB "~caselessCompare("ab"," ") -> 0 "ab "~caselessCompare("ab","x") -> 3 "abXX "~caselessCompare("ab","x") -> 5
>>-caselessCompareTo(string-+-----------------------+-)---------------------->< +-,--+---+--+---------+-+ +-n-+ +-,length-+
0
is returned. If the target string is larger, 1
is returned. -1
if the string argument is the larger string. The comparison is performed starting at character n for length characters in both strings. n must be a positive whole number. If n is omitted, the comparison starts at the first character. length must be a non-negative whole number. If omitted, the comparison will take place to the end of the target string.
Example 5.43. String class - caselessCompareTo method
"abc"~caselessCompareTo("abc") -> 0 "b"~caselessCompareTo("a") -> 1 "a"~caselessCompareTo("b") -> -1 "abc"~caselessCompareTo("aBc") -> 0 "aBc"~caselessCompareTo("abc") -> 0 "000abc000"~caselessCompareTo(111abc111", 4, 3) -> 0
>>-caselessCountStr(needle)--------------------------------------------><
Example 5.44. String class - caselessCountStr method
"a0Aa0A"~caselessCountStr("a") -> 4 "J0kKk0"~caselessCountStr("KK") -> 1
>>-caselessEquals(other)-----------------------------------------------><
Example 5.45. String class - caselessEquals method
"a"~caselessEquals("A") -> 1 "aa"~caselessEquals("A") -> 0 "4"~caselessEquals("3") -> 0
>>-caselessLastPos(needle-+---------------------------+-)--->< +-,--+-------+--+---------+-+ +-start-+ +-,length-+
0
if needle is the null string or not found. By default, the search starts at the last character of the receiving string and scans backward to the beginning of the string. You can override this by specifying start, the point at which the backward scan starts and length, the range of characters to scan. The start must be a positive whole number and defaults to receiving_string~length
if larger than that value or omitted. The length must be a non-negative whole number and defaults to start. The search is performed using caseless comparisons.
Example 5.46. String class - caselessLastPos method
"abc def ghi"~caselessLastPos(" ") -> 8 "abcdefghi"~caselessLastPos(" ") -> 0 "efgxyz"~caselessLastPos("XY") -> 4 "abc def ghi"~caselessLastPos(" ",7) -> 4 "abc def ghi"~caselessLastPos(" ",7,3) -> 0
>>-caselessMatch(start,other-+----------------------------+-)------------------->< +-,--+---+--+---------+------+ +-n-+ +-,length-+
Example 5.47. String class - caselessMatch method
"Saturday"~caselessMatch(6, "day") -> 1 "Saturday"~caselessMatch(6, "DAY") -> 1 "Saturday"~caselessMatch(6, "SUNDAY", 4, 3) -> 1 "Saturday"~caselessMatch(6, "daytime", 1, 3) -> 1
>>-caselessMatchChar(n,chars)-------------------------><
Example 5.48. String class - caselessMatchChar method
"a+b"~caselessMatchChar(2, "+-*/") -> 1 "a+b"~caselessMatchChar(1, "+-*/") -> 0 "Friday"~caselessMatchChar(3, "aeiou") -> 1 "FRIDAY"~caselessMatchChar(3, "aeiou") -> 1
>>-caselessPos(needle-+---------------------------+-)--->< +-,--+-------+--+---------+-+ +-start-+ +-,length-+
0
if needle is the null string or is not found or if start is greater than the length of the receiving string. The search is performed using caseless comparisons. By default, the search starts at the first character of the receiving string (that is, the value of start is 1
), and continues to the end of the string. You can override this by specifying start , the point at which the search starts, and length, the bounding limit for the search. If specified, start must be a positive whole number and length must be a non-negative whole number.
Example 5.49. String class - caselessPos method
"Saturday"~caselessPos("DAY") -> 6 "abc def ghi"~caselessPos("x") -> 0 "abc def ghi"~caselessPos(" ") -> 4 "abc def ghi"~caselessPos(" ",5) -> 8 "abc def ghi"~caselessPos(" ",5,3) -> 0
>>-caselessWordPos(phrase-+--------+-)--------------------------------->< +-,start-+
0
if phrase contains no words or if phrase is not found. Word matches are made independent of case. Several whitespace characters between words in either phrase or the receiving string are treated as a single blank for the comparison, but, otherwise, the words must match exactly.
Example 5.50. String class - caselessWordPos method
"now is the time"~caselessWordPos("the") -> 3 "now is the time"~caselessWordPos("The") -> 3 "now is the time"~caselessWordPos("IS THE") -> 2 "now is the time"~caselessWordPos("is the") -> 2 "now is the time"~caselessWordPos("is time ") -> 0 "To be or not to be"~caselessWordPos("BE") -> 2 "To be or not to be"~caselessWordPos("BE",3) -> 6
>>-ceiling-----------------------------------------------------><
receiving_string+0
had been carried out. The ceiling is then calculated and returned. The result is never in exponential form. If there are no nonzero digits in the result, any minus sign is removed.
Example 5.51. String class - ceiling method
2~ceiling -> 2 '-2'~ceiling -> -2 12.3~ceiling -> 13 '-12.3'~ceiling -> -12
Note
>>-+-center(-+-length-+--------+-)----------------------------->< +-centre(-+ +-,--pad-+
Note
Example 5.52. String class - center method
abc~center(7) -> " ABC " abc~CENTER(8,"-") -> "--ABC---" "The blue sky"~centre(8) -> "e blue s" "The blue sky"~centre(7) -> "e blue "
>>-changeStr(needle,newneedle--+--------+--)--------------------------------->< +-,count-+
Example 5.53. String class - changeStr method
101100~changeStr("1","") -> "000" 101100~changeStr("1","X") -> "X0XX00" 101100~changeStr("1","X",1) -> "X01100"
>>-compare(string-+------+-)----------------------------------->< +-,pad-+
0
if the argument string is identical to the receiving string. Otherwise, returns the position of the first character that does not match. The shorter string is padded on the right with pad if necessary. The default pad character is a blank.
Example 5.54. String class - compare method
"abc"~compare("abc") -> 0 "abc"~compare("ak") -> 2 "ab "~compare("ab") -> 0 "ab "~compare("ab"," ") -> 0 "ab "~compare("ab","x") -> 3 "ab-- "~compare("ab","-") -> 5
>>-compareTo(string-+-----------------------+-)---------------------->< +-,--+---+--+---------+-+ +-n-+ +-,length-+
0
is returned. If the target string is larger, 1
is returned. -1
if the string argument is the larger string. The comparison is performed starting at character n for length characters in both strings. n must be a positive whole number. If n is omitted, the comparison starts at the first character. length must be a non-negative whole number. If omitted, the comparison will take place to the end of the target string.
Example 5.55. String class - compareTo method
"abc"~compareTo("abc") -> 0 "b"~compareTo("a") -> 1 "a"~compareTo("b") -> -1 "abc"~compareTo("aBc") -> 1 "aBc"~compareTo("abc") -> -1 "000abc000"~compareTo(111abc111", 4, 3) -> 0
>>-copies(n)---------------------------------------------------><
>>-countStr(needle)--------------------------------------------><
Example 5.57. String class - countStr method
"101101"~countStr("1") -> 4 "J0KKK0"~CountStr("KK") -> 1
>>-d2c-+-----+------------------------------------------------->< +-(n)-+
Example 5.58. String class - d2c method
"65"~d2c -> "A" /* "41"x is an ASCII "A" */ "65"~d2c(1) -> "A" "65"~d2c(2) -> " A" "65"~d2c(5) -> " A" "109"~d2c -> "m" /* "6D"x is an ASCII "m" */ "-109"~d2c(1) -> "ô" /* "93"x is an ASCII "ô" */ "76"~d2c(2) -> " L" /* "4C"x is an ASCII " L" */ "-180"~d2c(2) -> " L"
>>-d2x-+-----+------------------------------------------------->< +-(n)-+
A
-F
and does not include whitespace.
Example 5.59. String class - d2x method
"9"~d2x -> "9" "129"~d2x -> "81" "129"~d2x(1) -> "1" "129"~d2x(2) -> "81" "129"~d2x(4) -> "0081" "257"~d2x(2) -> "01" "-127"~d2x(2) -> "81" "-127"~d2x(4) -> "FF81" "12"~d2x(0) -> ""
>>-dataType-+--------+----------------------------------------->< +-(type)-+
NUM
if you specify no argument and the receiving string is a valid Rexx number that can be added to 0 without error. It returns CHAR
if the receiving string is not a valid number.
1
if the receiving string matches the type. Otherwise, it returns 0
. If the receiving string is null, the method returns 0
(except when the type is X
or B
, for which dataType returns 1
for a null string). The following are valid types. You need to specify only the capitalized letter, or the number of the last type listed. The language processor ignores all characters surrounding it.
1
if the receiving string contains only characters from the ranges a
-z
, A
-Z
, and 0
-9
.
1
if the receiving string contains only the characters 0
or 1
, or whitespace. Whitespace characters can appear only between groups of 4 binary characters. It also returns 1 if string is a null string, which is a valid binary string.
1
if the receiving string contains only characters from the range a
-z
.
1
if the receiving string contains only characters from the ranges a
-z
and A
-Z
.
1
if receiving_string~dataType
returns NUM
.
1
if the receiving string is exactly "0" or "1". Otherwise it returns 0
.
1
if the receiving string is a valid symbol, that is, if SYMBOL(string) does not return BAD
. (See Section 1.10.4.4, “Symbols”.) Note that both uppercase and lowercase alphabetic characters are permitted.
1
if the receiving string contains only characters from the range A
-Z
.
1
if the receiving string could appear on the left-hand side of an assignment without causing a SYNTAX condition.
1
if the receiving string is a whole number under the current setting of NUMERIC DIGITS.
1
if the receiving string contains only characters from the ranges a
-f
, A
-F
, 0
-9
, and whitespace characters (as long as whitespace characters appear only between pairs of hexadecimal characters). Also returns 1
if the receiving string is a null string.
1
if receiving_string~dataType("W")
returns 1
when NUMERIC DIGITS is set to 9.
Example 5.60. String class - datatype method
" 12 "~dataType -> "NUM" ""~dataType -> "CHAR" "123*"~dataType -> "CHAR" "12.3"~dataType("N") -> 1 "12.3"~dataType("W") -> 0 "Fred"~dataType("M") -> 1 ""~dataType("M") -> 0 "Fred"~dataType("L") -> 0 "?20K"~dataType("s") -> 1 "BCd3"~dataType("X") -> 1 "BC d3"~dataType("X") -> 1 "1"~dataType("O") -> 1 "11"~dataType("O") -> 0
Note
>>-decodeBase64------------------------------------------------><
>>-delStr(n--+---------+--)------------------------------------>< +-,length-+
Example 5.62. String class - delStr method
"abcd"~delStr(3) -> "ab" "abcde"~delStr(3,2) -> "abe" "abcde"~delStr(6) -> "abcde"
>>-delWord(n--+---------+--)----------------------------------->< +-,length-+
Example 5.63. String class - delWord method
"Now is the time"~delWord(2,2) -> "Now time" "Now is the time "~delWord(3) -> "Now is " "Now is the time"~delWord(5) -> "Now is the time" "Now is the time"~delWord(3,1) -> "Now is time"
>>-encodeBase64------------------------------------------------><
>>-equals(other)-------------------------------------------------------><
Example 5.65. String class - equals method
"3"~equals("3") -> 1 "33"~equals("3") -> 0 "4"~equals("3") -> 0
>>-floor-------------------------------------------------------><
receiving_string+0
had been carried out. The floor is then calculated and returned. The result is never in exponential form. If there are no nonzero digits in the result, any minus sign is removed.
Example 5.66. String class - floor method
2~floor -> 2 '-2'~floor -> -2 12.3~floor -> 12 '-12.3'~floor -> -13
Note
>>-format-+---------------------------------------------------------+->< +-(-before-+------------------------------------------+-)-+ +-,--+-------+--+------------------------+-+ +-after-+ +-,--+------+--+-------+-+ +-expp-+ +-,expt-+
receiving_string+0
had been carried out. If you specify no arguments the result of the method is the same as the result of this operation. If you specify any options, the number is formatted as described in the following.
0
causes the number to be rounded to an integer.
Example 5.67. String class - format method
"3"~format(4) -> " 3" "1.73"~format(4,0) -> " 2" "1.73"~format(4,3) -> " 1.730" "-.76"~format(4,1) -> " -0.8" "3.03"~format(4) -> " 3.03" " - 12.73"~format(,4) -> "-12.7300" " - 12.73"~format -> "-12.73" "0.000"~format -> "0"
0
, the number is not an exponential expression. If expp is not large enough to contain the exponent, an error results.
0
, exponential notation is always used unless the exponent would be 0
. (If expp is 0
, this overrides a 0
value of expt.) If the exponent would be 0
when a nonzero expp is specified, then expp+2 blanks are supplied for the exponent part of the result. If the exponent would be 0
and expp is not specified, the number is not an exponential expression.
Example 5.68. String class - format method
"12345.73"~format(, ,2,2) -> "1.234573E+04" "12345.73"~format(,3, ,0) -> "1.235E+4" "1.234573"~format(,3, ,0) -> "1.235" "12345.73"~format(, ,3,6) -> "12345.73" "1234567e5"~format(,3,0) -> "123456700000.000"
>>-hashCode---------------------------------------------------><
>>-insert(new-+---------------------------------------+-)------>< +-,--+---+--+-------------------------+-+ +-n-+ +-,--+--------+--+------+-+ +-length-+ +-,pad-+
0
, which means insertion at the beginning of the string. If specified, n and length must be positive whole numbers or zero. If n is greater than the length of the receiving string, the string new is padded at the beginning. The default value for length is the length of new. If length is less than the length of the string new, then insert truncates new to length length. The default pad character is a blank.
Example 5.69. String class - insert method
"abc"~insert("123") -> "123abc" "abcdef"~insert(" ",3) -> "abc def" "abc"~insert("123",5,6) -> "abc 123 " "abc"~insert("123",5,6,"+") -> "abc++123+++" "abc"~insert("123", ,5,"-") -> "123--abc"
>>-lastPos(needle-+---------------------------+-)--->< +-,--+-------+--+---------+-+ +-start-+ +-,length-+
0
if needle is the null string or not found. By default, the search starts at the last character of the receiving string and scans backward to the beginning of the string. You can override this by specifying start, the point at which the backward scan starts and length, the range of characters to scan. The start must be a positive whole number and defaults to receiving_string~length
if larger than that value or omitted. The length must be a non-negative whole number and defaults to start.
Example 5.70. String class - lastPos method
"abc def ghi"~lastPos(" ") -> 8 "abcdefghi"~lastPos(" ") -> 0 "efgxyz"~lastPos("xy") -> 4 "abc def ghi"~lastPos(" ",7) -> 4 "abc def ghi"~lastPos(" ",7,3) -> 0
>>-left(length-+------+-)-------------------------------------->< +-,pad-+
>>-SUBSTR(string,1,length-+------+-)--------------------------->< +-,pad-+
Example 5.71. String class - left method
"abc d"~left(8) -> "abc d " "abc d"~left(8,".") -> "abc d..." "abc def"~left(7) -> "abc de"
>>-length------------------------------------------------------><
Example 5.72. String class - length method
"abcdefgh"~length -> 8 "abc defg"~length -> 8 ""~length -> 0
>>-lower(+---+--+---------+---)---------------------->< +-n-+ +-,length-+
Example 5.73. String class - lower method
"Albert Einstein"~lower -> "albert einstein" "ABCDEF"~lower(4) -> "ABCdef" "ABCDEF"~lower(3,2) -> "ABcdEF"
>>-makeArray(-+-----------+-)---->< +-Separator-+
Example 5.74. String class - makeArray method
string = "hello".endofline"world".endofline"this is an array." array = string~makeArray say "the second line is:" array[2] /* world */ string = "hello*world*this is an array." array = string~makeArray("*") say "the third line is:" array[3] /* this is an array. */ string = "hello*world*this is an array.*" array = string~makeArray("*") /* contains 3 items */
>>-makeString--------------------------------------------------><
>>-match(start,other-+----------------------------+-)------------------->< +-,--+---+--+---------+------+ +-n-+ +-,length-+
Example 5.75. String class - match method
"Saturday"~match(6, "day") -> 1 "Saturday"~match(6, "DAY") -> 0 "Saturday"~match(6, "Sunday", 4, 3) -> 1 "Saturday"~match(6, "daytime", 1, 3) -> 1
>>-matchChar(n,chars)-------------------------><
Example 5.76. String class - matchChar method
"a+b"~matchChar(2, "+-*/") -> 1 "a+b"~matchChar(1, "+-*/") -> 0 "Friday"~matchChar(3, "aeiou") -> 1 "FRIDAY"~matchChar(3, "aeiou") -> 0
>>-max-+------------------+------------------------------------>< | +-,------+ | | V | | +-(----number-+--)-+
Example 5.77. String class - max method
12~max(6,7,9) -> 12 17.3~max(19,17.03) -> 19 "-7"~max("-3","-4.3") -> -3 1~max(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21) -> 21
>>-min-+------------------+------------------------------------>< | +-,------+ | | V | | +-(----number-+--)-+
Example 5.78. String class - min method
12~min(6,7,9) -> 6 17.3~min(19,17.03) -> 17.03 "-7"~MIN("-3","-4.3") -> -7 21~min(20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) -> 1
>>-overlay(new-+---------------------------------------+-)----->< +-,--+---+--+-------------------------+-+ +-n-+ +-,--+--------+--+------+-+ +-length-+ +-,pad-+
1
. If you specify n, it must be a positive whole number.
Example 5.79. String class - overlay method
"abcdef"~overlay(" ",3) -> "ab def" "abcdef"~overlay(".",3,2) -> "ab. ef" "abcd"~overlay("qq") -> "qqcd" "abcd"~overlay("qq",4) -> "abcqq" "abc"~overlay("123",5,6,"+") -> "abc+123+++"
>>-pos(needle-+---------------------------+-)--->< +-,--+-------+--+---------+-+ +-start-+ +-,length-+
0
if needle is the null string or is not found or if start is greater than the length of the receiving string. By default, the search starts at the first character of the receiving string (that is, the value of start is 1
), and continues to the end of the string. You can override this by specifying start , the point at which the search starts, and length, the bounding limit for the search. If specified, start must be a positive whole number and length must be a non-negative whole number.
Example 5.80. String class - pos method
"Saturday"~pos("day") -> 6 "abc def ghi"~pos("x") -> 0 "abc def ghi"~pos(" ") -> 4 "abc def ghi"~pos(" ",5) -> 8 "abc def ghi"~pos(" ",5,3) -> 0
>>-replaceAt(new-,-n-,-+----------+-+-------+-)----->< +-,-length-+ +-,-pad-+
Example 5.81. String class - replaceAt method
"abcdef"~replaceAt(" ",3, 1) -> "ab def" "abcdef"~replaceAt(" ",3, 3) -> "ab f" "abc"~replaceAt("123",5,6,"+") -> "abc+123"
>>-reverse-----------------------------------------------------><
>>-right(length-+------+-)------------------------------------->< +-,pad-+
Example 5.83. String class - right method
"abc d"~right(8) -> " abc d" "abc def"~right(5) -> "c def" "12"~right(5,"0") -> "00012"
>>-round------------------------------------------------------><
receiving_string+0
had been carried out. The rounded value is then calculated and returned. The result is never in exponential form. If there are no nonzero digits in the result, any minus sign is removed.
Example 5.84. String class - round method
2~round -> 2 '-2'~round -> -2 2.4~round -> 2 '-2.4'~round -> -2 2.5~round -> 3 '-2.5'~round -> -3
Note
>>-sign--------------------------------------------------------><
receiving_string+0
had been carried out. It returns -1
if the receiving string is less than 0
, 0
if it is 0
, and 1
if it is greater than 0
.
>>-space-+---------------+------------------------------------->< +-(n-+------+-)-+ +-,pad-+
0
, all whitespace characters are removed. Leading and trailing whitespace characters are always removed. The default for n is 1
, and the default pad character is a blank.
Example 5.86. String class - space method
"abc def "~space -> "abc def" " abc def"~space(3) -> "abc def" "abc def "~space(1) -> "abc def" "abc def "~space(0) -> "abcdef" "abc def "~space(2,"+") -> "abc++def"
>>-strip-+----------------------+------------------------------->< +-(option-+--------+-)-+ +-,chars-+
Example 5.87. String class - strip method
" ab c "~strip -> "ab c" " ab c "~strip("L") -> "ab c " " ab c "~strip("t") -> " ab c" "12.7000"~strip(,0) -> "12.7" "0012.700"~strip(,0) -> "12.7" "0012.000"~strip(,".0"") -> "12"
>>-subchar(n)----------------------------------------------><
>>-substr(n-+-------------------------+-)---------------------->< +-,--+--------+--+------+-+ +-length-+ +-,pad-+
receiving_string~length
, only pad characters are returned.
Example 5.88. String class - substr method
"abc"~substr(2) -> "bc" "abc"~substr(2,4) -> "bc " "abc"~substr(2,6,".") -> "bc...."
Note
>>-subWord(n-+---------+-)------------------------------------->< +-,length-+
Example 5.89. String class - subWord method
"Now is the time"~subWord(2,2) -> "is the" "Now is the time"~subWord(3) -> "the time" "Now is the time"~subWord(5) -> ""
>>-subWords(--+---+-+---------+-)------------------------------------->< +-n-+ +-,length-+
Example 5.90. String class - subWords method
"Now is the time"~subWords -> .array~of("Now", "is", "the", "time") "Now is the time"~subWords(2,2) -> .array~of("is", "the") "Now is the time"~subWords(3) -> .array~of("the", "time") "Now is the time"~subWords(5) -> .array~new(0)
Example 5.91. String class - subWords method
do word over source~subWords -- extract all of the words to loop over say word end
>>-translate-+--------------------------------------------------------------------------+->< +-(--+-------------------------------------+-+-----------------------+-)---+ +-tableo--+-------------------------+-+ +-,--+---+--+---------+-+ +-,--+--------+--+------+-+ +-n-+ +-,length-+ +-tablei-+ +-,pad-+
a
-z
to uppercase A
-Z
), but if you include pad the entire string is translated to pad characters. tablei defaults to XRANGE("00"x,"FF"x)
, and tableo defaults to the null string and is padded with pad or truncated as necessary. The default pad is a blank.
Example 5.92. String class - translate method
"abcdef"~translate -> "ABCDEF" "abcdef"~translate(, , , 3, 2) -> "abCDef" "abcdef"~translate("12", "ec") -> "ab2d1f" "abcdef"~translate("12", "abcd", ".") -> "12..ef" "APQRV"~translate(, "PR") -> "A Q V" "APQRV"~translate(XRANGE("00"X, "Q")) -> "APQ " "4123"~translate("abcd", "1234", , 2, 2) -> "4ab3" "4123"~translate("abcd", "1234") -> "dabc"
Note
>>-trunc-+-----+----------------------------------------------->< +-(n)-+
0
and returns an integer with no decimal point. If you specify n, it must be a positive whole number or zero. The receiving string is first rounded according to standard Rexx rules, as though the operation receiving_string+0
had been carried out. This number is then truncated to n decimal places or trailing zeros are added if needed to reach the specified length. The result is never in exponential form. If there are no nonzero digits in the result, any minus sign is removed.
Example 5.93. String class - trunc method
12.3~trunc -> 12 127.09782~trunc(3) -> 127.097 127.1~trunc(3) -> 127.100 127~trunc(2) -> 127.00
Note
>>-upper(+---+--+---------+---)---------------------->< +-n-+ +-,length-+
Example 5.94. String class - upper method
"Albert Einstein"~upper -> "ALBERT EINSTEIN" "abcdef"~upper(4) -> "abcDEF" "abcdef"~upper(3,2) -> "abCDef"
>>-verify(reference-+----------------------------------------------+-)-->< +-,--+--------+--+---------------------------+-+ +-option-+ +-,--+-------+--+---------+-+ +-start-+ +-,length-+
0
if all characters in the receiving string are in reference or returns the position of the first character in the receiving string not in reference.
Nomatch
(the default) or Match
. (You need to specify only the first capitalized and highlighted letter; all characters following the first character are ignored)
Match
, the method returns the position of the first character in the receiving string that is in reference, or returns 0
if none of the characters are found.
1
. Thus, the search starts at the first character of the receiving string. You can override this by specifying a different start point, which must be a positive whole number.
0
, regardless of the value of the option. Similarly, if start is greater than receiving_string~length
, the method returns 0
. If reference is null, the method returns 0
if you specify Match
. Otherwise, the method returns the start value.
Example 5.95. String class - verify method
"123"~verify("1234567890") -> 0 "1Z3"~verify("1234567890") -> 2 "AB4T"~verify("1234567890") -> 1 "AB4T"~verify("1234567890","M") -> 3 "AB4T"~verify("1234567890","N") -> 1 "1P3Q4"~verify("1234567890", ,3) -> 4 "123"~verify("",N,2) -> 2 "ABCDE"~verify("", ,3) -> 3 "AB3CD5"~verify("1234567890","M",4) -> 6 "ABCDEF"~verify("ABC","N",2,3) -> 4 "ABCDEF"~verify("ADEF","M",2,3) -> 4
>>-word(n)-----------------------------------------------------><
receiving_string~subWord(n,1)
.
Example 5.96. String class - word method
"Now is the time"~word(3) -> "the" "Now is the time"~word(5) -> ""
>>-wordIndex(n)------------------------------------------------><
0
if the receiving string has fewer than n words. The n must be a positive whole number.
Example 5.97. String class - wordIndex method
"Now is the time"~wordIndex(3) -> 8 "Now is the time"~wordIndex(6) -> 0
>>-wordLength(n)-----------------------------------------------><
0
if the receiving string has fewer than n words. The n must be a positive whole number.
Example 5.98. String class - wordLength method
"Now is the time"~wordLength(2) -> 2 "Now comes the time"~wordLength(2) -> 5 "Now is the time"~wordLength(6) -> 0
>>-wordPos(phrase-+--------+-)--------------------------------->< +-,start-+
0
if phrase contains no words or if phrase is not found. Several whitespace characters between words in either phrase or the receiving string are treated as a single blank for the comparison, but, otherwise, the words must match exactly.
Example 5.99. String class - wordPos method
"now is the time"~wordPos("the") -> 3 "now is the time"~wordPos("The") -> 0 "now is the time"~wordPos("is the") -> 2 "now is the time"~wordPos("is the") -> 2 "now is the time"~wordPos("is time ") -> 0 "To be or not to be"~wordPos("be") -> 2 "To be or not to be"~wordPos("be",3) -> 6
>>-words-------------------------------------------------------><
>>-x2b---------------------------------------------------------><
Example 5.101. String class - x2b method
"C3"~x2b -> "11000011" "7"~x2b -> "0111" "1 C1"~x2b -> "000111000001"
Example 5.102. String class - x2b method with c2x
"C3"x~c2x~x2b -> "11000011" "129"~d2x~x2b -> "10000001" "12"~d2x~x2b -> "1100"
>>-x2c---------------------------------------------------------><
Example 5.103. String class - x2c method
"4865 6c6c 6f"~x2c -> "Hello" /* ASCII */ "3732 73"~x2c -> "72s" /* ASCII */
>>-x2d-+-----+------------------------------------------------->< +-(n)-+
0
.
Example 5.104. String class - x2d method
"0E"~x2d -> 14 "81"~x2d -> 129 "F81"~x2d -> 3969 "FF81"~x2d -> 65409 "46 30"X~x2d -> 240 /* ASCII */ "66 30"X~x2d -> 240 /* ASCII */
0
, the method returns 0
.
0
characters (note, not "sign-extended"), or truncated on the left to n characters.
Example 5.105. String class - x2d method
"81"~x2d(2) -> -127 "81"~x2d(4) -> 129 "F081"~x2d(4) -> -3967 "F081"~x2d(3) -> 129 "F081"~x2d(2) -> -127 "F081"~x2d(1) -> 1 "0031"~x2d(0) -> 0
Table 5.4. ooRexx Method Class
Object | |
↓ | |
Method | |
new newFile loadExternalMethod | |
isGuarded isPrivate isProtected package setGuarded |
setPrivate setProtected setSecurityManager setUnguarded source |
Note
>>-new(name,source--+-------------+---)------------------->< +--, context--+
>>-newFile(filename)-------------------------------------------><
>>-loadExternalMethod(name,descriptor)------------------------><
Example 5.106. Method class - loadExternalMethod method
method = .Method~loadExternalMethod("homeAddress=", 'LIBRARY mylib setHomeAddress')
>>-isGuarded--------------------------------------------------><
>>-isPrivate--------------------------------------------------><
>>-isProtected--------------------------------------------------><
>>-package-----------------------------------------------------><
>>-setGuarded--------------------------------------------------><
>>-setPrivate--------------------------------------------------><
>>-setProtected------------------------------------------------><
>>-setSecurityManager--+---------------------------+----------->< +-(security_manager_object)-+
>>-setUnguarded------------------------------------------------><
Table 5.5. ooRexx Routine Class
Object |
↓ |
Routine |
new newFile loadExternalRoutine |
call callWith package setSecurityManager source |
Note
>>-new(name,source--+-------------+---)------------------->< +--, context--+
>>-newFile(filename)-------------------------------------------><
>>-loadExternalRoutine(name,descriptor)------------------------><
Example 5.107. Routine class - loadExternalRoutine method
routine = .Routine~loadExternalRoutine("Pi", "LIBRARY rxmath RxCalcPi")
>>-call-+--------------------+------------------------------------>< | +-,--------+ | | V | | +-(----argument-+--)-+
>>-call(array)----------------------------------------------------><
>>-package-----------------------------------------------------><
Table 5.6. ooRexx Package Class
Object | |
↓ | |
Package | |
new | |
addClass addPackage addPublicClass addPublicRoutine addRoutine classes definedMethods digits findClass findRoutine form fuzz importedClasses importedPackages importedRoutines |
loadLibrary loadPackage name publicClasses publicRoutines routines setSecurityManager source sourceLine sourceSize trace |
Note
>>-new(name,source--+------------------+---)------------------->< +--, methodobject--+
>>-addClass(name,class)----------------------------------------><
>>-addPackage(package)----------------------------------------><
>>-addPublicClass(name,class)----------------------------------><
>>-addPublicRoutine(name,routine)----------------------------------------><
>>-addRoutine(name,routine)----------------------------------------><
>>-classes----------------------------------------------><
>>-definedMethods----------------------------------------------><
>>-digits------------------------------------------------------><
>>-findClass(name)---------------------------------------------><
>>-findRoutine(name)---------------------------------------------><
>>-form--------------------------------------------------------><
>>-fuzz--------------------------------------------------------><
>>-importedClasses--------------------------------------><
>>-importedPackagess-------------------------------------><
>>-importedRoutines-------------------------------------><
>>-loadLibrary(name)-----------------------------------------><
>>-loadPackage(name-+---------+-)---------------------------->< +-,source-+
>>-publicClasses--------------------------------------><
>>-publicRoutines-------------------------------------><
>>-routines-------------------------------------><
>>-setSecurityManager--+---------------------------+----------->< +-(security_manager_object)-+
>>-source------------------------------------------------------><
>>-sourceLine(n)------------------------------------------------------><
>>-sourceSize---------------------------------------------------------><
>>-trace-------------------------------------------------------><
Table 5.7. ooRexx Message Class
Object | |
↓ | |
Message | |
new | |
arguments completed errorCondition hasError messageName |
notify result send start target |
Note
>>-new(target,messagename-+-------------------------------+-)-->< | +---------------+ | | V | | +-,Individual---+-----------+-+-+ | +-,argument-+ | +-,Array,argument---------------+
Note
>>-arguments----------------------------------------------><
>>-completed---------------------------------------------------><
1
if the message object has completed executing its message, or 0
. You can use this method to test for completion as an alternative to calling result and waiting for the message to complete.
>>-errorCondition----------------------------------------------><
>>-hasError----------------------------------------------------><
1
if the message object's message was terminated with an error condition. Returns 0
if the message has not completed or completed without error.
>>-messageName----------------------------------------------><
>>-notify(message)---------------------------------------------><
Example 5.108. Message class - notify method
/* Event-driven greetings */ .prompter~new~prompt(.nil) ::class prompter ::method prompt expose name use arg msg if msg \= .nil then do name = msg~result if name = "quit" then return say "Hello," name end say 'Enter your name ("quit" to quit):' /* Send the public default object .INPUT a LINEIN message asynchronously */ msg=.message~new(.input,"LINEIN")~~start /* Sends self~prompt(msg) when data available */ msg~notify(.message~new(self,"PROMPT","I",msg)) /* Don't leave until user has entered "quit" */ guard on when name="quit"
>>-result------------------------------------------------------><
Example 5.109. Message class - result method
/* Example using result method */ string="700" /* Create a new string object, string */ bond=string~start("reverse") /* Create a message object, bond, and */ /* start it. This sends a REVERSE */ /* message to string, giving bond */ /* the result. */ /* Ask bond for the result of the message */ say "The result of message was" bond~result /* Result is 007 */
>>-send--+----------+------------------------------------------>< +-(target)-+
>>-start--+----------+----------------------------------------->< +-(target)-+
Example 5.110. Message class - start method
/* Using Message class methods */ /* Note: In the following example, ::METHOD directives define class Testclass */ /* with method SHOWMSG */ ez=.testclass~new /* Creates a new instance of Testclass */ mymsg=ez~start("SHOWMSG","Hello, Ollie!",5) /* Creates and starts */ /* message mymsg to send */ /* SHOWMSG to ez */ /* Continue with main processing while SHOWMSG runs concurrently */ do 5 say "Hello, Stan!" end /* Get final result of the SHOWMSG method from the mymsg message object */ say mymsg~result say "Goodbye, Stan..." exit ::class testclass public /* Directive defines Testclass */ ::method showmsg /* Directive creates new method SHOWMSG */ use arg text,reps /* class Testclass */ do reps say text end reply "Bye Bye, Ollie..." return
Hello, Ollie! Hello, Stan! Hello, Ollie! Hello, Stan! Hello, Ollie! Hello, Stan! Hello, Ollie! Hello, Stan! Hello, Ollie! Hello, Stan! Bye Bye, Ollie... Goodbye, Stan...