NUM()

NUM(), NUMS()

Top  Previous  Next

 

The NUM() function tests whether a string can be converted to a number. The NUMS() function is similar to NUM() but operates on successive elements of a dynamic array, returning a similarly structured dynamic array of results.

 

 

Format

 

NUM(string)

 

where

 

stringevaluates to the string to be tested.

 

 

The NUM() function returns True if the string can be converted to a number. The function returns False for a string which cannot be converted to a number. A null string is a valid representation of zero and hence causes NUM() to return True.

 

If the NUMERIC.EXPONENT mode of the OPTION command is enabled, The NUM() function will accept exponent style values such as 123.45E-1 as being numeric.

 

 

Example

 

LOOP

  DISPLAY "Enter part number ":

  INPUT PART.NO

UNTIL LEN(PART.NO) AND NUM(PART.NO)

  PRINTERR "Part number is invalid"

REPEAT

 

This program fragment prompts for and inputs a part number. If the data entered is null or cannot be converted to a number, an error message is displayed and the prompt is repeated.