StripNewLine Function
#1

Where i can find StripNewLine ?? my dutils give this error ( undefine symbol StripNewLine )
Reply
#2

Lol sorry offtopic, but checkout your signature,
sizeof(256) really?
Reply
#3

PHP код:
stock DINI_StripNewLine(string[]) {
    new 
len strlen(string);
    if (
string[0]==0) return ;
    if ((
string[len 1] == '\n') || (string[len 1] == '\r')) {
        
string[len 1] = 0;
        if (
string[0]==0) return ;
        if ((
string[len 2] == '\n') || (string[len 2] == '\r')) string[len 2] = 0;
    }
}
stock DINI_fcopytextfile(oldname[],newname[]) {
    new 
File:ohnd,File:nhnd;
    if (!
fexist(oldname)) return false;
    
ohnd=fopen(oldname,io_read);
    if (!
ohnd) return false;
    
nhnd=fopen(newname,io_write);
    if (!
nhnd) {
        
fclose(ohnd);
        return 
false;
    }
    new 
tmpres[DINI_MAX_STRING];
    while (
fread(ohnd,tmpres)) {
        
DINI_StripNewLine(tmpres);
        
format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
        
fwrite(nhnd,tmpres);
    }
    
fclose(ohnd);
    
fclose(nhnd);
    return 
true;

- Dracoblue (Dini).

OffTopic; Rofl @ Signature.
Reply
#4

Quote:
Originally Posted by tyler12
Посмотреть сообщение
PHP код:
stock DINI_StripNewLine(string[]) {
    new 
len strlen(string);
    if (
string[0]==0) return ;
    if ((
string[len 1] == '\n') || (string[len 1] == '\r')) {
        
string[len 1] = 0;
        if (
string[0]==0) return ;
        if ((
string[len 2] == '\n') || (string[len 2] == '\r')) string[len 2] = 0;
    }
}
stock DINI_fcopytextfile(oldname[],newname[]) {
    new 
File:ohnd,File:nhnd;
    if (!
fexist(oldname)) return false;
    
ohnd=fopen(oldname,io_read);
    if (!
ohnd) return false;
    
nhnd=fopen(newname,io_write);
    if (!
nhnd) {
        
fclose(ohnd);
        return 
false;
    }
    new 
tmpres[DINI_MAX_STRING];
    while (
fread(ohnd,tmpres)) {
        
DINI_StripNewLine(tmpres);
        
format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
        
fwrite(nhnd,tmpres);
    }
    
fclose(ohnd);
    
fclose(nhnd);
    return 
true;

- Dracoblue (Dini).

OffTopic; Rofl @ Signature.
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)