SA-MP Forums Archive
function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: function (/showthread.php?tid=268988)



function - BaubaS - 14.07.2011

Hi, maybe someone have a good idea how to create function which would check if there are numbers and letters in string?

I have idea for this, but its long


Re: function - Toreno - 14.07.2011

This checks if string is numeric,
pawn Код:
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}



Re: function - Adil - 14.07.2011

Late...(forums don't warn you no more if someone has posted while you were writing)


Re: function - BaubaS - 14.07.2011

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
This checks if string is numeric,
pawn Код:
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
I think this will check is the string are integer.


Re: function - Toreno - 14.07.2011

And what integer is? number.


Re: function - BaubaS - 15.07.2011

Cant understand, but nvm. So, the check sould be something like (IN DIALOG)

if(!strlen(inputtext)) && !IsNumeric(inputtext)


Re: function - Flyfishes - 15.07.2011

No.

if(strlen(inputtext) && !IsNumeric(inputtext))
This checks if the string includes any text and it shouldn't include numbers to pass