integerfn wildness(string (*)name s)
integer k,i,w=0
for i=1,1,length(s) cycle
k = charno(s,i); w = w+1 if k='*' or k='%'
repeat
result = w
end
predicate Matches(string (*) name s, p)
! S=Subject, P=Pattern. Pattern is the one with the stars in it.
integer slen = 0, plen = 0
predicate m (integer spos,ppos)
integer psym = 0,ssym = 0
cycle
if ppos=plen start
true if spos=slen
false
finish
ppos = ppos+1; psym = charno(p,ppos)
exitif psym='*'
falseif spos=slen
spos = spos+1; ssym = charno(s,spos)
psym = ssym if ssym!32=psym!32 and 'a'<=psym!32<='z'
unless ssym=psym start
falseunless psym='%'
finish
repeat
cycle
trueif m(spos,ppos)
exitif spos=slen
spos = spos+1; ssym = charno(s,spos)
repeat
false
end
slen = length(s)
plen = length(p)
true if m(0,0)
false
end