Index · Preferences · Help
Policy · Discussion · AI · Calculations · Engine · Graphics · Interface · Lists · Movement · Objects · Players · Samples · Saving · Sound · Text · Time · Turfs · Utility
Forum Search:

[Advanced Search]

[Messages in this Thread] [Show All (6)] [Return to Text]

Author:Metamorphman [Posts]
Date:9/22/09 8:24 am
Topic:IsNum()
Post ID:306
Next ID:307
/*
Title: IsNum()
Credit To: Metamorphman
Contributed By: Metamorphman

This proc returns true if the specified string is: 
1.A number 
or 
2.A text string, containing nothing but numbers. 

Useful for validating things like PIN Codes.
*/

proc/IsNum( string )

    if( isnum( string ) )
        return 1

    if( !istext( string ) )
        return

    for( var/x = 1 to length( string ) )
        var/currentChar = text2ascii( string , x )
        if( currentChar > 57 || currentChar < 48 ) return 0

    return 1

Messages in this Thread: [Show All (6)]

  IsNum() Metamorphman (9/22/09 8:24 am)
      Re: IsNum() Kuraudo (9/24/09 7:27 pm)
          Re: IsNum() Kaioken (9/30/09 8:20 pm)
              Re: IsNum() Kuraudo (9/30/09 8:32 pm)
                  Re: IsNum() Kaioken (9/30/09 9:16 pm)
          Re: IsNum() Metamorphman (9/25/09 3:02 am)