The logical function ALPHA evaluates an expression to determine if it is a string containing only alphabetic characters.
Format
ALPHA(expr) |
Parameter(s)
expr |
String expression to be tested. |
Description
The ALPHA function determines whether the expression is an alphabetic or nonalphabetic string. If the expression contains the characters A through Z or a through z (ASCII 65 - 90, 97 - 122), it evaluates to true and a value of 1 is returned. If the expression contains any other character (such as numeric or special characters), it evaluates to false and a value of 0 is returned.
Examples
If the variable NAME contains "HENRY FRENKL", then:
ALPHA(NAME) |
returns 1. However, if NAME contains "HENRY FRENKL4th", the ALPHA function returns 0.
In the next application, airline reservations require the traveler’s starting point and final destination. The travel agent must enter these with the 3-letter code assigned to airports.
PROMPT " " PRINT @(-1) PRINT @(2,2) : "ENTER FLIGHT DATE: ": INPUT @(30,2) DATE "D" PRINT @(2,4) : "ENTER FLIGHT NUMBER: ": INPUT @(30,4) FLTNO,3 "0" PRINT @(2,6) : "STARTING POINT: ": LOOP INPUT @(30,6) START,3 IF NOT ( ALPHA( START )) THEN INPUTERR "PLEASE ENTER 3-LETTER AIRPORT CODE." END UNTIL ALPHA(START) DO REPEAT PRINT @(2,8) : "FINAL DESTINATION: ": LOOP INPUT @(30,8) DEST,3 IF NOT( ALPHA( DEST )) THEN INPUTERR "PLEASE ENTER 3-LETTER AIRPORT CODE." END UNTIL ALPHA(DEST) DO REPEAT |
See Also