String check
#1

Example:
pawn Код:
new str[] = "Nick (ID): Some Text\nNick (ID): Some Text\nNick (ID): Some Text\nNick (ID): Some Text\n";
pawn Код:
CheckMsg(str); // if line have more than 20 characters strdel a strins [...]
Result:
pawn Код:
str = "Nick (ID): Some [...]\nNick (ID): Some [...]\nNick (ID): Some [...]\nNick (ID): Some [...]";
Can someone show me how can I do this stock CheckMsg ?

Thats my stock but something is wrong with lengh += len;

pawn Код:
stock CheckMsg(txt[],s_size = sizeof(txt))
{
    new str[128],pos;
    pos = 4; // lines in txt[]
    new i,idx,lengh = 0;

    while(i != pos)
    {
        str = strtok(txt, idx, '\n');
        new len = strlen(str) + 2;
        printf("len: %d - %s",len,str);
        if(len-2 > MIN_TXT)
        {
            strdel(str,MIN_TXT,idx-1);
            strins(str," [...]",MIN_TXT);
            //print(str);

            len = strlen(str) + 1;
            strdel(txt,lengh,idx-1);
            strins(txt,str,lengh,s_size);
            print(txt);
        }
        lengh += len;
        //printf("lengh: %d",lengh);
        idx = len;
        i++;
    }
}
Reply
#2

So u want if the string contains "\n" split it and store it in another string ?
Reply
#3

No if the string (one line) lenght > 20 strdel 20 to \n and strins in pos 20 [...] then go to the next line and do the same
Reply
#4

Thanks all for helping
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)