|
The HLA IN operator combined with character sets can dramatically reduce the logic in your HLA programs. This text has waited until now to discuss this operator because certain forms require a knowledge of character sets and character set constants. Now that you've seen character set constants, there is no need to delay the introduction of this important language feature.
In addition to the standard boolean expressions in if, while, repeat..until, and other statements, HLA also supports boolean expressions that take the following forms:
reg8 in CSetConstant reg8 not in CSetConstant reg8 in CSetVariable reg8 not in CSetVariable
These four forms of the in and not in operators check to see if a character in an 8-bit register is a member of a character set (either a character set constant or a character set variable). The following code fragment demonstrates these operators:
const Alphabetic: cset := {'a'..'z', 'A'..'Z'}; . . . stdin.getc(); if( al in Alphabetic ) then stdout.put( "You entered an alphabetic character" nl ); elseif( al in {'0'..'9'} ) then stdout.put( "You entered a numeric character" nl ); endif;
|