home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / pg / pggene / match.tip < prev    next >
Text File  |  2006-10-19  |  1KB  |  44 lines

  1. 0 REM MATCH.TIP (c) 1990 by P.Globman
  2. 10 LINEINPUT"TARGET$ ";T$
  3. 20 LINEINPUT"MATCH$  ";M$
  4. 30 GOSUB100:PRINT:PRINT"Match ";
  5. 40 IF NOT FOUND THEN PRINT"not ";
  6. 50 PRINT"found!":PRINT:PRINT
  7. 60 GOTO10
  8. 100 REM----------------- MATCH ROUTINE
  9. 101 REM match string (M$) and target
  10. 102 REM string (T$) defined before 
  11. 103 REM this GOSUB.  Upon return from
  12. 104 REM here, variable FOUND (FO) is
  13. 105 REM true (-1) if match exists, and
  14. 106 REM false (0) otherwise.
  15. 107 REM 
  16. 108 REM Within M$, "!" will match any
  17. 109 REM upper or lower case letter, "#"
  18. 110 REM will match any digit (0-9), and
  19. 111 REM "?" will match any character.
  20. 112 REM
  21. 115 FOUND=0:P0=LEN(T$)-LEN(M$)+1:P1=1
  22. 120 IFP0<1THENRETURN
  23. 125 FOUND=-1:FORP2=1TOLEN(M$)
  24. 130 P3=ASC(MID$(M$,P2,1))
  25. 135 P4=ASC(MID$(T$,P2+P1-1,1))
  26. 140 IF P3=63 THEN 175
  27. 145 IF P3<>35 THEN 155
  28. 150 IF(P4>47)AND(P4<58)THEN175
  29. 155 IF P3<>33 THEN 170
  30. 160 IF(P4>64)AND(P4<91)THEN175
  31. 165 IF(P4>96)AND(P4<123)THEN175
  32. 170 IF P3<>P4 THEN FOUND=0:GOTO180
  33. 175 NEXT:RETURN
  34. 180 P1=P1+1:IFP1>P0THENRETURNELSE125
  35.  
  36. Variables P0 thru P4 are use so as not 
  37. to conflict with variables used in 
  38. elsewhere in the program.  Make changes
  39. as necessary but use caution.
  40.  
  41. The routine is NOT case insensitve for
  42. exact letter matches, but could be made
  43. so.
  44.