[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Replace within a Save/Get



I've often wished I could do a CI (change invisible) within a
Save/Get as easily as I can do it to text displayed on-screen.
Here's a fragment of code that lets you do that. It's
case-sensitive (I haven't figured out how to make it not so),
but you can use wildcards in it. Note that the fragment is set
up as a dialog box file routine so that you can simply jump to
it with a JM function call. But you could easily strip out the
header and smileys (ASCII2) and use the code elsewhere.

{{5,ChangeSG}}
[ASCII2][ASCII238][less-than]0>
;*;
++>;*; -- End
here if you want just one change.
[ASCII238][less-than]0>
[ASCII2]

All < and > are chevrons, euroquotes, whatever. The less-than
character is [less-than].

Note a few things: (1) If you incorporate just the code into
your own routines, make sure the Loop has a unique name. (2)
Input is in S/G 40.  Output is also in S/G 40. (3) SubString to
be changed is in S/G 41; the string to change it to is in S/G
42. (4) Every instance of the substring will be changed. If
you want to change just the first substring found, you can modify
 the code by eliminating the loop and putting  at the end of
the third line (excluding the header). (5) If you want to
report "Cannot find item" if the substring isn't found, you can
put BX (beep) just before the  in the
first line.

You can put wildcards into S/G 41 by using the Escape character
(Shift+Esc on most Xy keyboards) followed by the letters that
would have represented the wildcard. Don't use wildcards
themselves unless you mean them as literals in the string. For
instance, the wildcard letter is [Esc]L. This is
case-sensitive; [Esc]x won't work but [Esc]X will.

Contest update:
I'm in the process of reading through the contest entries and
putting the finishing touches on the "prize". I'll keep you
posted.

Tim Baehr