home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 1995 May / pcw-0595.bin / demos / databeck / wsounds / setup.dir / wswsrc.exe / STRTOOL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-03  |  2KB  |  91 lines

  1. UNIT StrTool;
  2.  
  3. INTERFACE
  4.  
  5. USES Strings;
  6.  
  7. function STRHasWildcards(FileName: PChar): Boolean;
  8. Function STRInstring(P1, P2 : Pchar) : Boolean;
  9. Function STRCheckSub(Srch : PChar; Pre : PChar; Switch : Byte) : Boolean;
  10.  
  11. IMPLEMENTATION
  12.  
  13. function STRHasWildcards(FileName: PChar): Boolean;
  14. begin
  15.   STRHasWildcards := (StrScan(FileName, '*') <> nil)
  16.   { or  (StrScan(FileName, '?') <> nil)};
  17. end;
  18.  
  19. Function STRInstring(P1, P2 : Pchar) : Boolean;
  20. VAR
  21.    Count : Integer;
  22.    Check : Integer;
  23.    P1len : Integer;
  24.    P2Len : Integer;
  25.    TestChar : Char;
  26. BEGIN
  27.    P1Len := StrLen(P1);
  28.    P2Len := StrLen(P2);
  29.    FOR Count := 0 to (P2Len-P1Len) do BEGIN
  30.       Check := 0;
  31.       Repeat
  32.          IF ((Count+Check) <= P2Len) THEN
  33.           {WriteLn(P1[Check],' - > ',P2[Count+Check]);}
  34.           TestChar := P2[Count+Check];
  35.           IF TestChar = 'Σ' Then TestChar := '─';
  36.           IF TestChar = '÷' Then TestChar := '╓';
  37.           IF TestChar = 'ⁿ' Then TestChar := '▄';
  38.           IF (P1[Check] = TestChar) THEN Inc(Check)
  39.                                            ELSE Check := -1;
  40.          Until ((Check < 0) OR (Check >= P1Len));
  41.          IF (Check = P1Len) THEN BEGIN
  42.             STRInstring := TRUE;
  43.             {
  44.             WriteLn('Whoopee...');
  45.             }
  46.             Exit;
  47.             END;
  48.       END;
  49.    STRInstring := False;
  50.    END;
  51.  
  52. Function STRCheckSub(Srch : PChar; Pre : PChar; Switch : Byte) : Boolean;
  53. BEGIN
  54.  
  55.    IF (StrLen(Srch) = 0) THEN BEGIN
  56.    Case Switch of
  57.     0 : StrCheckSub := True;  { AND }
  58.     1 : StrCheckSub := True;  { OR  }
  59.     2 : StrCheckSub := True; { Not }
  60.     END;
  61.     Exit;
  62.     END;
  63.  
  64.    IF ((StrLen(Srch) <> 0) AND (StrLen(Pre) = 0)) THEN BEGIN
  65.    Case Switch of
  66.     0 : StrCheckSub := FALSE;  { AND }
  67.     1 : StrCheckSub := FALSE;  { OR  }
  68.     2 : StrCheckSub := TRUE; { Not }
  69.     END;
  70.     Exit;
  71.     END;
  72.  
  73.    IF (STRInstring(StrUpper(Srch),StrUpper(Pre)) =True) Then
  74.    Case Switch of
  75.     0 : StrCheckSub := True;  { AND }
  76.     1 : StrCheckSub := True;  { OR  }
  77.     2 : StrCheckSub := False; { Not }
  78.     END
  79.    ELSE
  80.    Case Switch of
  81.     0 : StrCheckSub := False; { AND }
  82.     1 : StrCheckSub := False; { OR  }
  83.     2 : StrCheckSub := True;  { Not }
  84.     END; 
  85.    END; 
  86.  
  87.  
  88.  
  89. BEGIN
  90.    END.
  91.