Older Version Newer Version

bshipps64 bshipps64 Feb 19, 2006 - "Fixed potential bug"

StringChop$ function

A small function to remove any occurrences of one string from another.

  • The brand new StringChop$ 9000!!! IT SLICES!! IT DICES!! (Does not Julienne at this time). This function simply locates the position of a 'find' string within a 'source' string, grabs everything before and after it, combines those two as a new 'source' string and repeats the process on that. Voila! Perfect potatoes every time! Delicious test program included! Enjoy!
input "Original string: "; orig$
if (orig$ = "") then end
 
[loop]
    input "Character(s) to chop: "; chop$
    if (chop$ = "") then end
 
    orig$ = StringChop$(orig$, chop$)
    if (orig$ = "") then end
 
    print "Chopped string: "; orig$
    goto [loop]
 
function StringChop$(StringChop$,c$)
    cLen = len(c$)
    do
        cPos        = instr(StringChop$,c$)
 
        if not(cPos) then exit do
 
        pre$        = left$(StringChop$, cPos - 1)
        post$       = mid$(StringChop$,  cPos + cLen)
        StringChop$ = pre$ + post$
    loop while 1
end function