ALPHA()

ALPHA()

Top  Previous  Next

 

The ALPHA() function tests whether a string contains only alphabetic characters.

 

 

Format

 

ALPHA(string)

 

where

 

stringevaluates to the string to be tested.

 

 

The ALPHA() function returns True if string contains only alphabetic characters (A to Z, a to z). The function returns False for a null string or a string that contains non-alphabetic characters.

 

Use of ALPHA() is a faster equivalent to using pattern matching against a pattern of "1A0A".

 

 

Example

 

LOOP

  DISPLAY "Enter surname ":

  INPUT NAME

WHILE NOT(ALPHA(NAME))

  PRINTERR "Name is invalid"

REPEAT

 

This program fragment prompts for and inputs a name. If the name is null or contains non-alphabetic characters, an error message is displayed and the prompt is repeated.

 

 

See also:

Pattern matching, NUM()