Product Site

5.1.7.33. caselessAbbrev

Returns 1 if info is equal to the leading characters of the receiving string and the length of info is not less than length. Returns 0 if either of these conditions is not met. The characters are tested using a caseless comparison.

If you specify length, it must be a positive whole number or zero. The default for length is the number of characters in info.
Example 5.72. String class — caselessAbbrev method
Say "Print"~caselessAbbrev("Pri")      -->    1
Say "PRINT"~caselessAbbrev("Pri")      -->    1
Say "PRINT"~caselessAbbrev("PRI",4)    -->    0
Say "PRINT"~caselessAbbrev("PRY")      -->    0
Say "PRINT"~caselessAbbrev("")         -->    1
Say "PRINT"~caselessAbbrev("",1)       -->    0

Note

A null string always matches if a length of 0, or the default, is used. This allows a default keyword to be selected automatically if desired.
Example 5.73. String class — caselessAbbrev method
say "Enter option:";   parse pull option .
select  /* keyword1 is to be the default */
  when "keyword1"~caselessAbbrev(option) then ...
  when "keyword2"~caselessAbbrev(option) then ...
  /* ... */
  otherwise nop;
end;