Author Topic: Isnumber()  (Read 2005 times)

Offline S. P. Gardebiter

  • Mr. Polyvector
  • ***
  • Posts: 245
    • View Profile
    • Tile 44 Interactive
Isnumber()
« on: 2010-Dec-01 »
Ich arbeite momentan etwas mit der Commandline. Eine Funktion die überprüft ob ein Wert eine "Zahl" ist oder Buchstaben beinhaltet wäre sehr vorteilhaft D;

Edit: I see, I forget "to english":

I'm currently working with the commandline a bit. A function that checks if a value is a "number" or contains letters would be kinda nice.
« Last Edit: 2010-Dec-01 by S. P. Gardebiter »
~ Cave Story rules! ~

MrTAToad

  • Guest
Re: Isnumber()
« Reply #1 on: 2010-Dec-02 »
You could check by making sure each character is between 0 and 9, + or - and, if accepting decimal points '.'

Letters would be harder depending on how international you want the check.

It may be easier to just interface with the is isnum and isalpha C commands using INLINE

INLINE
  extern "C" isnum(char one);
  extern "C" isalpha(char one);
ENDINLINE

and then write a function to check each letter for numbers and/or characters