home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rox.zip
/
collect.rox
< prev
next >
Wrap
Text File
|
1993-08-28
|
2KB
|
80 lines
:*------------------------------------------------------------------
:* REXX Object eXtensions : collection class
:*------------------------------------------------------------------
:class collection
:*------------------------------------------------------------------
:* methods that need to be overridden
:*------------------------------------------------------------------
:method atIndex
parse source . . me .
say me ": for object of class" RoxClass(self)
say me ": this method needs to be overriden in a subclass"
return self
:method size
parse source . . me .
say me ": for object of class" RoxClass(self)
say me ": this method needs to be overriden in a subclass"
return self
:*------------------------------------------------------------------
:* return boolean indicating whether given item is found in the
:* collection
:*------------------------------------------------------------------
:method includes
test = arg(1)
if ("string" = RoxClass(test)) then
string = 1
else
string = 0
do i = 1 to .size(self)
item = .atIndex(self,i)
if string then
bool = (test = item)
else
bool = .equal(test,item)
if (bool) then
return 1
end
return 0
:*------------------------------------------------------------------
:* walk over items in the collection, executing code
:*
:* .do(obj,var,code<,init<,term>>)
:* var - variable to set to the current item in the collection
:* code - code to execute for each item - variable 'var' (above)
:* will be set to the value of the current item
:* init - code to run before walking collection
:* term - code to run after walking collection
:*------------------------------------------------------------------
:method do
!!var = arg(1)
!!code = arg(2)
!!size = .size(self)
!!self = self
result = ""
if (arg() >= 3) & (arg(3) <> "") then
interpret arg(3)
do !!i = 1 to !!size
!!item = .atIndex(!!self,!!i)
interpret !!var "= !!item;" !!code
end
if (arg() >= 4) & (arg(4) <> "") then
interpret arg(4)
return result