HP 3000 Manuals

NLS Pattern Match [ COMMUNICATOR 3000/XL Release 1.2, Version A.20.10 ] MPE/iX Communicators


COMMUNICATOR 3000/XL Release 1.2, Version A.20.10

NLS Pattern Match 

by Jesse Chin--Commercial Systems Division 

Native Language Support (NLS) provides the HP3000 with the features
necessary to produce localized application programs for end users without
reprogramming for each country or language.  Several MPE commands and
subsystems allow the user to specify a set of values by using an
expression as the pattern to be matched in ASCII character set.  NLS
pattern match allows the users to define the patterns and data in their
native languages.

PATTERN MATCH INTRINSICS 

The pattern description and grammar are the ones used in VPLUS, see HP 
Data Entry and Forms Management System VPLUS/3000 (P/N 32209-60002)
section IV under "Pattern Match." Two NLS intrinsics, NLMATCHINIT and
NLMATCH, are implemented to support NLS pattern match.  A pattern
consists of a series of special characters that indicate the type of data
to be selected.  These characters are:

        a    Uppercase, lowercase, or 16 bit Asian character.
        u    Uppercase alphabetic character.
        l    Lowercase alphabetic character.
        b    Blank (space).
        d    Digit as defined in the NLS character attribute table.
        ?    Any character.

Other metacharacters indicate choice, grouping, and ranges:

        !    Transparency.
        ,    Choice.
        :    Range.
        { }  Grouping,
        [ ]  Optional.
        +    Repetition (1 or more).
        *    Repetition (0 or more).

The pattern operators are evaluated in the following order, where x,y are
any character for the language:

        !    Transparency.                     !x
        :    Range.                            x:y
        +/*  Repetition (1/0 or more).         x+ or x*
             Concatenation.                    xy
        ,    Choice.                           x,y


NOTE The Repetition, Concatenation and Choice operators can be used with patterns: i.e x,y are any pattern in this case.
NLMATCHINIT Compiles a pattern into a form for use with the NLMATCH intrinsic. Syntax I BA I IV result := NLMATCHINIT ( pattern, pattern'length, langid, BA I compiled'pattern, compile'buf'size ); Functional Return Zero is returned in result if the compilation of pattern is successful. Otherwise result contains the error code. Error Code Meaning 001 NLS is not installed. 002 Specified language is not configured. 101 Missing "]" or "}" operators. 102 Expecting alpha symbols. 104 Incomplete pattern specified. 105 Bad range operation specified. 203 Pattern too big. 900 Internal state machine error. Parameters pattern A byte array containing the pattern to be compiled. Leading and trailing spaces will be ignored. pattern'length An integer indicates the length in bytes of the pattern to be compiled. langid The language id number of the language to be used in compiling the pattern. compiled'pattern A byte array specifying where the compiled pattern should be constructed. compile'buf'size ^ma The length of the compiled'pattern, in bytes, available for constructing the compiled pattern. Additional Discussion This procedure converts the regular expression in pattern to a reduced finite state machine, placed in compiled'pattern. Pattern'length is the expression's length (in bytes) and compile'buf'size is the maximum size of compiled'pattern (bytes). If compile'buf'size is 0, then just a syntax check of pattern is performed, no compiled'pattern will be generated. If NLMATCHINIT returns 0, then everything is OK. If compile'buf'size > 0, then compiled'pattern contains the compiled pattern and compile'buf'size contains its actual size (bytes). If NLMATCHINIT isn't 0, it's an error number. In that case, pattern'length contains the 0-origin index into pattern of how far we've gotten in the scan (possibly all the way). NLMATCH Compares a string against a pattern which has previously been compiled with the NLMATCHINIT intrinsic. Syntax I BA BA IV result := NLMATCH ( compiled'pattern, string, length ); Functional Return Zero is returned in result if the string matches the compiled pattern. If it does not match then the mismatch location is returned. Error Code Meaning 1 NLS is not installed. 2 Specified language is not configured. 100+n n is the mismatch location. Parameters compiled'pattern A byte array containing the compiled form of a pattern as returned by NLMATCHINIT. string The string to be compared against the pattern. length Length, in bytes, of the string to be compared.


MPE/iX Communicators