Letter Substitution

By Wilf Hey

Have you ever been in the situation where you needed to change a particular letter in a text string? Recently I had to change "#" into the Sterling pound sign "£" throughout a source. Well, it's a pretty simple thing to do, but you may find it a tricky little problem. Here's my solution:

sub$ = chr$(163)
do
 a = instr$(X$, "#")
 if a>0 then
  X$ = left$(X$,a-1);sub$;right$(X$,a+1)
 end if
loop until a = 0

This little loop replaces each "#" with chr$(163) in the string X$: just do this for each record before you "print" it out to the new version of the file