strreplace issue
#4

pawn Код:
stock strreplace2(string[], const find[], const replace[], bool:ignorecase=false, count=cellmax, maxlength=sizeof(string))
{
    if(isnull(find) || isnull(string)) return 0;
    new matches;
    for(new idx, flen = strlen(find), rlen = strlen(replace), pos = strfind(string, find, ignorecase); pos != -1 && idx < maxlength && matches < count; pos = strfind(string, find, ignorecase, idx)) {
        strdel(string, pos, pos + flen);
        if(rlen) strins(string, replace, pos, maxlength);   // Crashy
        idx = pos + rlen;
        matches++;
    }
    return matches;
}
pawn Код:
public OnFilterScriptInit()
{
    new string[128];
    format(string, sizeof(string), "This is only a test, so don't ask!");
    print(string);
    strreplace2(string, "test", "foo");
    print(string);
    return 1;
}
Reply


Messages In This Thread
strreplace issue - by Victor - 29.11.2010, 13:26
Re: strreplace issue - by MadeMan - 29.11.2010, 14:33
Re: strreplace issue - by MadeMan - 29.11.2010, 14:40
Re: strreplace issue - by [03]Garsino - 29.11.2010, 14:46

Forum Jump:


Users browsing this thread: 1 Guest(s)