IsInteger (Closed)
#1

Hi,
I'm looking for a function, which checks, if a text that is input from dialog, is a integer.
I've already use the search function but I didn't find anything useful.

I hope you can help me

- Raicoon
Reply
#2

Out of my head

pawn Код:
stock IsInteger(text[])
{
  if(strval(text) == 0)
  {
    return false
  }
  return true;
}
Reply
#3

And what if he will enter "0" into that dialog?
Reply
#4

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

pawn Код:
stock IsNumeric(string[])
{
  for(new o; o<strlen(string);o++)
  {
    if((string[o]>'9')||(string[0]<'0'))return 0;
  }
  return 1;
}
bah, he beat me.
Reply
#6

Ok it works. Thanks //exora and Joe Staff your codes helped me a lot!

- Raicoon
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)