home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / arexx / moos / demos / rexx_stem.rexx < prev    next >
OS/2 REXX Batch file  |  1997-03-18  |  5KB  |  188 lines

  1. /*
  2.  * rexx_[SUB].library
  3.  *
  4.  * Test file...
  5.  */
  6.  
  7. OPTIONS RESULTS
  8. lib = 'rexxMOOS.library'; IF ~SHOW('L',lib) THEN CALL ADDLIB(lib,100,-30)
  9.  
  10.                                                                               
  11. /*
  12.  *    StemSearch()
  13.  */
  14. CALL print(4,'#',"StemSearch(pattern,options)")
  15.  
  16. CALL print(20,'-',"Input stem")
  17. in.  = "Example entry..."
  18. in.0 = 20
  19. DO n = 1 TO in.0 - 1 BY 2
  20.     in.n = "random" RANDU()
  21. END
  22. DO n = 1 FOR in.0; SAY "IN."n "==" in.n; END
  23.  
  24. CALL print(20,'-',"StemSearch('Ex#?','in.* out.* Case')")
  25. IF StemSearch('Ex#?','in.* out.* Case') THEN
  26.     DO n = 1 FOR out.0; SAY out.n; END
  27.  
  28. CALL print(20,'-',"StemSearch('#?dom#?','in.* out. Pos 12')")
  29. IF StemSearch('#?dom#?','in.* out. Pos 12') THEN
  30.     DO n = 0 FOR out.count; SAY out.n; END
  31.  
  32. DROP in. out.
  33.  
  34.                                                                               
  35. /*
  36.  *    StemCopy()
  37.  */
  38. CALL print(4,'#',"StemCopy(options)")
  39.  
  40. CALL print(20,'-',"Destination stem")
  41. to.count = 12
  42. DO i = 0 FOR to.count
  43.     to.i.post = "to stem" i
  44. END
  45. DO i = 0 FOR to.count; SAY "TO."i".POST ==" to.i.post; END
  46.  
  47. CALL print(20,'-',"Source stem")
  48. from. = "From stem...."
  49. from.count = 5
  50. DO i = 0 FOR from.count; SAY "FROM."i "==" from.i; END
  51.  
  52. CALL print(20,'-',"StemCopy('from. to.#.post ToPos 2')")
  53. IF StemCopy('from. to.#.post ToPos 2') THEN
  54.     DO i = 0 FOR to.count; SAY "TO."i".POST ==" to.i.post; END
  55.  
  56. CALL print(20,'-',"StemCopy('to.#.post out.foo.bar. Tot 5')")
  57. IF StemCopy('to.#.post out.foo.bar. Tot 5') THEN
  58.     DO i = 0 FOR out.foo.bar.count
  59.         SAY "OUT.FOO.BAR."i "==" out.foo.bar.i
  60.     END
  61.  
  62. DROP to. from. out.
  63.  
  64.                                                                               
  65. /*
  66.  *    StemInsert()
  67.  */
  68. CALL print(4,'#',"StemInsert(from,options)")
  69.  
  70. CALL print(20,'-',"Destination stem")
  71. to.count = 20
  72. DO i = 0 FOR to.count
  73.     to.i.post = "To stem" i; SAY to.i.post
  74. END
  75.  
  76. CALL print(20,'-',"Source stem")
  77. from. = "From stem...."
  78. from.0 = 5
  79. DO i = 1 FOR from.0; SAY from.i; END
  80.  
  81. CALL print(20,'-',"StemInsert('from.*','to.#.post ToPos 2')")
  82. IF StemInsert('from.*','to.#.post ToPos 2') THEN
  83.     DO i = 0 FOR to.count; SAY to.i.post; END
  84.  
  85. DROP to. from.
  86.  
  87.                                                                               
  88. /*
  89.  *    StemSort()
  90.  */
  91. CALL print(4,'#',"StemSort(pattern,options)")
  92.  
  93. CALL print(20,'-',"Input stem")
  94. in.count = 20
  95. DO n = 0 FOR in.count
  96.     in.n = WORD(ERRORTEXT(n+10),RANDU()*2%1+1); SAY in.n
  97. END
  98.  
  99. CALL print(20,'-',"StemSort('in. out.*')")
  100. IF StemSort('in. out.*') THEN
  101.     DO n = 1 FOR out.0; SAY out.n; END
  102.  
  103. CALL print(20,'-',"StemSort('in. out. Case')")
  104. IF StemSort('in. out. Case') THEN
  105.     DO n = 0 FOR out.count; SAY out.n; END
  106.  
  107. CALL print(20,'-',"Input stem")
  108. in.0 = 20
  109. DO n = 1 FOR in.0
  110.     in.n = COPIES(D2C(65+32*(RANDU()*2%1)+2*(RANDU()*10%1)),10)
  111. END
  112. DO n = 1 FOR in.0; SAY in.n; END
  113.  
  114. CALL print(20,'-',"StemSort('in.* out. Descend NoDupes')")
  115. IF StemSort('in.* out. Descend NoDupes') THEN
  116.     DO n = 0 FOR out.count; SAY out.n; END
  117.  
  118. DROP in. out.
  119.  
  120.                                                                               
  121. /*
  122.  *    StemRemove()
  123.  */
  124. CALL print(4,'#',"StemRemove(options)")
  125.  
  126. CALL print(20,'-',"Input stem")
  127. in.count = 20
  128. DO i = 0 FOR in.count
  129.     in.i = "stem" i; SAY in.i
  130. END
  131.  
  132. CALL print(20,'-',"StemRemove('in. FromPos 4 Tot 5')")
  133. IF StemRemove('in. FromPos 4 Tot 5') THEN
  134.     DO i = 0 FOR in.count; SAY in.i; END
  135.  
  136. CALL print(20,'-',"Input stem")
  137. in.0 = 20
  138. DO i = 1 FOR in.0; in.i = "in."i 1*1000; SAY in.i; END
  139.  
  140. CALL print(20,'-',"StemRemove('in.* FromPos 4 ToPos 12')")
  141. IF StemRemove('in.* FromPos 4 ToPos 12') THEN
  142.     DO i = 1 FOR in.0; SAY in.i; END
  143.  
  144. DROP in.
  145.  
  146.                                                                               
  147. /*
  148.  *    StemWrite()
  149.  */
  150. CALL print(4,'#',"StemWrite(file,options)")
  151.  
  152. CALL print(20,'-',"StemWrite('T:prova','txt.')")
  153. txt.count = 20
  154. DO n = 0 FOR txt.count
  155.     txt.n = "This is the" n"th test"; SAY txt.n
  156. END
  157. IF StemWrite("T:prova","txt.") THEN DO
  158.     ADDRESS COMMAND 'Type "T:prova"'
  159.     ADDRESS COMMAND 'Delete "T:prova"'
  160. END
  161.  
  162. DROP txt.
  163.  
  164.                                                                               
  165. /*
  166.  *    StemRead()
  167.  */
  168. CALL print(4,'#',"StemRead(file,options)")
  169.  
  170. CALL print(20,'-',"StemRead('S:Startup-Sequence','txt.*')")
  171. IF StemRead("S:Startup-Sequence","txt.*") THEN
  172.     DO n = 1 FOR txt.0; SAY txt.n; END
  173.  
  174. DROP txt.
  175.  
  176.                                                                               
  177.  
  178. ADDRESS COMMAND 'Wait' 2
  179.  
  180. SAY
  181. EXIT 0
  182.  
  183. print: PROCEDURE
  184.     PARSE ARG pos,char,str
  185.     IF char = '#' THEN SAY '0a0a'x
  186.     SAY COPIES(char,pos) || OVERLAY(" "str" ",COPIES(char,78 - pos))
  187.     RETURN
  188.