home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
568a.lha
/
RexxRMF_v1.1
/
test.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-09-11
|
3KB
|
87 lines
/* This example illustrates how to use 'low level' AVL-tree functions */
/* for simple indexing, nothing meaningful is done here. */
x = addlib("RexxRMF.library",0,-30,0)
ix = open_rmf() /* no data file or index file will be created */
/* simply using search/sort capabilities of AVL */
/* cannot save the index, cuz we did not open it with a name */
if ix = '0000 0000'x then exit
p = showlist('P') /* build list of names */
do forever /* insert names from showlist() into tree */
/* insertion occurs such that the names */
/* are sorted in alphabetical order */
if p = '' then leave
parse var p port p /* parse out a name */
z = add_key(ix,0,port,0) /* add name to the tree */
end
do i = 1 to 100
treenode = find_pos(ix,0,i) /* find by position (ie. in sorted order) */
if treenode = '0000 0000'x then leave
say " Node " i '=' key_value(treenode) /* print value of key */
end
do i = 1 to 8
z = add_key(ix,0,"Ron_nie",0) /* add a key into the tree */
end
z = add_key(ix,0,"RHONDA",0) /* add some more keys into the tree */
z = add_key(ix,0,"RHONDA",0)
z = add_key(ix,0,"RHONDA",0)
z = add_key(ix,0,"RONNIE",0)
z = add_key(ix,0,"RONNIE",0)
z = add_key(ix,0,"RONNIE",0)
akey = find_key(ix,0,"IDCMP",1) /* find key IDCMP in our tree */
do until akey = '0000 0000'x
if akey ~= '0000 0000'x then
say "FOUND KEY" key_value(akey) "occurence" key_occur(akey) "position" node_pos(akey)
akey = find_next(ix,0)
end
string = "R"
akey = locate_key(ix,0,string,1) /* will locate any key beginning with "R" */
do until akey = '0000 0000'x
if akey ~= '0000 0000'x then
say "LOCATED KEY" key_value(akey) "occurence" key_occur(akey) "position" node_pos(akey)
akey = locate_next(ix,0)
end
z = delete_key(ix,0,"RHONDA",1) /* delete first occurence of RHONDA */
/* will cause mulitples occur number */
/* to be adjusted accordingly */
z = delete_key(ix,0,"RHONDA",1) /* what was occurence #2 is now occur */
/* occur #1 */
do i = 1 to 100
treenode = find_pos(ix,0,i) /* find by position (ie. in sorted order) */
if treenode = '0000 0000'x then leave
say " Node " i '=' key_value(treenode) /* print value of key */
end
x = close_rmf(ix,0) /* close index, releasing mem used */
exit