home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol12n08.zip / MATCH.ZIP / TSTMATCH.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-27  |  2KB  |  62 lines

  1. PROGRAM TstMatch;
  2. USES WinDos, Strings,
  3. {$IFDEF Windows} WinCrt, WinTypes, WinProcs;
  4. {$ELSE}
  5.   {$IFNDEF DPMI} Requires BP7's protected mode target
  6.   {$ENDIF}
  7. Crt, WinApi;
  8. {$ENDIF}
  9. TYPE MatchFunc = FUNCTION(Mask, Name : pChar) : boolean;
  10. VAR
  11.   hLibrary : tHandle;
  12.   Matches  : MatchFunc;
  13.   pGraf    : PChar;
  14.  
  15.   PROCEDURE TestMatch(P1, P2 : PChar; wid : Integer);
  16.   BEGIN
  17.     Write(P2:wid, ' <-> ', P1, '':wid-StrLen(P1), ' match=');
  18.     WriteLn(Matches(P1, P2));
  19.   END;
  20.  
  21. BEGIN
  22.   ClrScr;
  23.   hLibrary := LoadLibrary('match.dll');
  24.   IF hLibrary < 32 THEN
  25.     BEGIN
  26.       WriteLn('Cannot load library MATCH.DLL');
  27.       Halt;
  28.     END;
  29.   TFarProc(@Matches) := GetProcAddress(hLibrary, 'Matches');
  30.   IF TFarProc(@Matches) = NIL THEN
  31.     BEGIN
  32.       FreeLibrary(hLibrary);
  33.       WriteLn('Cannot locate function "Matches"');
  34.       Halt;
  35.     END;
  36.   TestMatch('P*C***M*A*G', 'PEACEMAKING', 15);
  37.   TestMatch('*E*D*C*E', 'HEADACHE', 15);
  38.   TestMatch('?E?D?C?E', 'HEADACHE', 15);
  39.   TestMatch('*E*D*C*E', 'EDCE', 15);
  40.   TestMatch('?E?D?C?E', 'EDCE', 15);
  41.   TestMatch('*E*D*C*E', 'EDC', 15);
  42.   TestMatch('H??D*', 'HEADACHE', 15);
  43.   TestMatch('H??D*', 'HEAD', 15);
  44.   TestMatch('H??D????', 'HEADACHE', 15);
  45.   TestMatch('H??D????', 'HEAD', 15);
  46.   WriteLn;
  47.   TestMatch('*A*E*I*O*U*Y*', 'FACETIOUSLY', 15);
  48.   TestMatch('*A*E*I*O*U*Y*', 'ABSTEMIOUSLY', 15);
  49.   WriteLn;
  50.   TestMatch('C*D.*M', 'COMMAND.COM', 15);
  51.   TestMatch('CO*OM', 'COMMAND.COM', 15);
  52.   WriteLn;
  53.   TestMatch('*', 'Anything At All', 15);
  54.   WriteLn;
  55.   TestMatch('*the tide*',
  56.     '"Just the place for a snark!", the Bellman cried,'^M^J+
  57.     'As he landed his crew with care,'^M^J+
  58.     'Supporting each man on the top of the tide'^M^J+
  59.     'By a finger entwined in his hair.'^M^J, 0);
  60.   FreeLibrary(hLibrary);
  61. END.
  62.