.ABBRV - check for valid abbreviation.

Alternate Entry Name: _ABBRV

Usage:

B:
   score = .abbrv( pattern, string );
C:
   #include <sdgstd.h>
   int _abbrv(char *pattern, char *string);

Description:

.ABBRV is used by the setup routine .BSET to determine if "string" is a valid abbreviation of "pattern". If "string" is not a valid abbreviation, -1 is returned. If "string" is a valid abbreviation, .ABBRV returns a numerical score which indicates how well "string" matches "pattern". Higher scores indicate better matches.

"string" is a pointer to some B string. .ABBRV ignores whether the letters in "string" are upper or lower case.

"pattern" is a pointer to the full string which is to be matched. Characters which must appear in valid abbreviations should be given in upper case; other characters which can appear in abbreviations should be given in lower case. .ABBRV assumes that all non-alphabetic characters except '_' in "pattern" must be matched for a valid abbreviation.

A valid abbreviation is a string containing all the necessary (upper case) characters in the correct order; other (lower case) characters in the "pattern" may appear in the abbreviation, but characters which are not in the "pattern" may not appear.

The score function (for a valid abbreviation) gives one point for each lower case character matched. The score function gives 1024 points for each upper case or non-alphabetic character matched. For the pattern "eXtract" (note the upper and lower cases) the following results would be obtained.

string          score
"x"             1024
"ex"            1025
"extr"          1027
"extrat"        1029
"xtrt"          1027
"extract"       1030
"e"              -1
"tract"          -1
"xtray"          -1

See Also:

expl b lib .bset

Copyright © 1996, Thinkage Ltd.