10.02.2011, 18:29
Hi,
I've just made an "IsValidMailAddr" function, but it isn't working how I want it to work.
It's only working one time... ?
Here's the function
And the test in OnGameModeInit:
As you can see, "Mail 4" is the same as "Mail". But this is the output in the console:
It says from mail 4 that it isn't OK, while MAIL is OK.
Thanks if you can help me.
- Kevin
I've just made an "IsValidMailAddr" function, but it isn't working how I want it to work.
It's only working one time... ?
Here's the function
pawn Код:
stock IsValidMailAddr(addr[])
{
new l = 0,
atcount, bool:IsValid = false
;
l = strlen(addr);
loop:l(i){
if(addr[i] == '@') atcount++;
if( ( (addr[i] >= 'a' && addr[i] <= 'z') || (addr[i] >= 'A' && addr[i] <= 'Z') || (addr[i] == '-') || (addr[i] == '.') ) && atcount == 1 )
IsValid = true;
else{
IsValid = false;
break;
}
if(i == l-1){
if(!((addr[i] >= 'a' && addr[i] <= 'z') || (addr[i] >= 'A' && addr[i] <= 'Z'))){
IsValid = false;
break;
}
}
}
return IsValid ? true : false;
}
pawn Код:
if(IsValidMailAddr("kwarde@rpdsamp.nl")) print("MAIL OK"); else print("MAIL NOT OK"); //MAIL
if(IsValidMailAddr("kwarde@@rpdsamp.nl")) print("MAIL 2 OK"); else print("MAIL 2 NOT OK"); //MAIL 2
if(IsValidMailAddr("kwarde@rpdsamp.nl.")) print("MAIL 3 OK"); else print("MAIL 3 NOT OK"); //MAIL 3
if(IsValidMailAddr("kwarde@rpdsamp.nl")) print("MAIL 4 OK"); else print("MAIL 4 NOT OK"); //MAIL 4
if(IsValidMailAddr("k,warde@rpdsamp.nl")) print("MAIL 5 OK"); else print("MAIL 5 NOT OK"); //MAIL 5
Код:
MAIL OK MAIL 2 NOT OK MAIL 3 NOT OK MAIL 4 NOT OK MAIL 5 NOT OK
Thanks if you can help me.
- Kevin