HTBasic Help
×
Menu
Index

User-Defined UPC$/LWC$ Rules

 
In addition to specifying order rules, HTBasic has been enhanced to let you specify upper and lowercase conversion rules as well. This capability is an extension to HTBasic and will not work if used with HP BASIC. However, HP BASIC will not return an error; the UPC$/LWC$ rules will simply be ignored.
 
Note: There is some danger in specifying meaningless upper/lowercase rules because HTBasic uses these rules in checking the syntax of a command or program line. For example, when you type "RUN", UPC$("RUN") is compared against the list of known statements. As long as you take reasonable care in defining your rules, you shouldn’t have any problems.
Upper/lowercase rules are stored in the LEXICAL ORDER IS array immediately following the special case table. The UPC$/LWC$ table consists of 257 elements. The first element must have the value 21576 to indicate that the UPC$/LWC$ table is present. The rules themselves are stored in the next 256 elements, one for each possible character. All 256 characters must be defined. In each element, the upper byte contains the UPC$ value and the lower byte contains the LWC$ value.
 
For example, in the USERDEF.BAS example above, the special case table ends at element A(260). Element A(261) should be assigned a value of 21576 if upper/lowercase rules are also being specified. Elements A(262) through A(517) would contain the rules for CHR$(0) through CHR$(255). To set the UPC$/LWC$ values for "A" and "a", the following statements would be used:
 
A(257+A(256))=21576
A(258+A(256)+NUM("A"))=SHIFT( NUM("A"),-8)+NUM("a")
A(258+A(256)+NUM("a"))=SHIFT( NUM("A"),-8)+NUM("a")
 
The subscript calculation in this example deserves some explanation. If the array BASE is zero then A(256) is the length of the special case table, 257+A(256) is the first element after the special case table, and 258+A(256)+NUM("x") is the UPC$/LWC$ definition for "x".
 
Of course, it is best to simplify these statements to:
 
A(261)=21576
A(327)=16737
A(359)=16737