04.02.2011, 13:38
Alternative version of "IsNumeric"
How does it work:
It loops through the whole 'string' length. If string length 'i' (per character) is numeric, it increases 'check' with 1.
If 'check' is the same as the string length, it will return true.
It's easy :P
pawn Код:
stock IsNumeric(string[])
{
for(new i = 0, length = strlen(string), check; i < length; i++){
switch(string[i]){
case '0' .. '9': check ++;
}
if(check == length) return true;
}
return false;
}
It loops through the whole 'string' length. If string length 'i' (per character) is numeric, it increases 'check' with 1.
If 'check' is the same as the string length, it will return true.
It's easy :P