ALPHA() |
![]() ![]() ![]() |
The ALPHA() function tests whether a string contains only alphabetic characters.
Format
ALPHA(string)
where
The ALPHA() function returns true (1) if string contains only alphabetic characters (A to Z, a to z). The function returns false (0) for a null string or a string that contains non-alphabetic characters.
Use of ALPHA() is 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. |