4.18 The IN Operator in HLA HLL Boolean Expressions


4.18 The IN Operator in HLA HLL Boolean Expressions

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; 




The Art of Assembly Language
The Art of Assembly Language
ISBN: 1593272073
EAN: 2147483647
Year: 2005
Pages: 246
Authors: Randall Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net