Remove char procedure

Just starting out? Need help? Post your questions and find answers here.
rominfo
New User
New User
Posts: 5
Joined: Sat Apr 26, 2003 2:34 pm
Location: Italy
Contact:

Remove char procedure

Post 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... :?
PureBasic e PureVision registered users
Image
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post 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:
Beware of the man who has the solution before he understands the problem...
Post Reply