Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!apdoo From: apdoo@alice.UUCP (Alan Weiss) Newsgroups: comp.sys.handhelds Subject: More search and replace Keywords: A small improvement Message-ID: <10612@alice.UUCP> Date: 22 Mar 90 22:10:55 GMT Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 33 Just a followup on the search and replace function I posted a day ago...typing in the program, I noticed that the use of MULTI could be eliminated and the program would be faster. So I did it. Here is the new search and replace function, with new timing info: Benchmarks: CHR 0 to "V" in a STR-> string: his 92 sec, mine 80 sec,now 76 sec Replace a string of 10 "Z" characters with 10 "U" chars: his 1.6 sec, mine .97 sec,now .71 sec The new and old substrings do not have to be the same length; indeed, the biggest use I have for this program is stripping out newline characters and replacing them with empty strings. CHG2 [checksum 5AFC] 3: String to change 2: Old substring -----> 1: New substring 1:Changed string << -> x y << WHILE DUP x POS DUP REPEAT DUP2 1 - 1 SWAP SUB 3 ROLLD 1 + OVER SIZE SUB y SWAP + + END DROP >> >> Alan Weiss, AT&T Bell Labs inet!research.att.com!apdoo