Page 1 of 1

Remove char procedure

Posted: Wed May 14, 2003 11:02 am
by rominfo
hello, everyone

can you help me to optimize the procedure below?

Code: Select all

Procedure.s RemoveChar(String1.s, String2.s)
    Protected nCiclo.b, nLen2.b, cResult.s
    
    nLen2 = Len(String2)
    cResult = String1
    
    For nCiclo = 1 To nLen2
        cResult = RemoveString(cResult, Mid(String2, nCiclo, 1))
    Next
    ProcedureReturn cResult
EndProcedure

; {test procedure}
a.s = "ABCDEFG"
b.s = "AF"
debug RemoveChar(a, b)
thanks... :?

Posted: Thu May 15, 2003 5:46 pm
by Skipsy
Hi Rominfo,

Well...
RemoveString works a strange way... (or I should stop drinking :wink: )

The following seems working better but I don't know why :

Procedure.s RemoveChar(String1.s, String2.s)
Protected nCiclo.b, nLen2.b, cResult.s

nLen2 = Len(String2)
cResult = String1

For nCiclo = 1 To nLen2
temp$ = Mid(String2, nCiclo, 1)
cResult = RemoveString(cResult, temp$)
Next
ProcedureReturn cResult
EndProcedure

Is it a PB bug ? :?: :wink: