0 Glob (Pattern Matching)

This routine performs a primitive type of pattern matching. Its main use in the TI-83+/TI-84+ implementation of BBC BASIC (Z80) is filtering filenames when using the *DIR command.


pattern$ defines the pattern to check input$ against. result% is the output of the routine and will equal TRUE if input$ matched pattern$, FALSE otherwise.

The pattern can contain one of two wildcard characters:

The pattern is case-insensitive. Here are some examples of patterns:

pattern$ input$ result%
test test TRUE
cat dog FALSE
*og dog TRUE
*og frog TRUE
b??k bank TRUE
b??k book TRUE
b??k brick FALSE
b*k brick TRUE

pattern$ and input$ can be movable or fixed strings. They may not contain NUL or CR characters. result% can be a real or integer variable.

BASIC wrapper function

You can wrap up the routine as a standard BASIC function using the following snippet:


You could then invoke it like this:

IF FN_glob("*ee*", "Sheep") PRINT "Matches." ELSE PRINT "Does not match."

which would output