home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dbadv.zip / PEEKFIND.PRG < prev    next >
Text File  |  1986-02-25  |  2KB  |  56 lines

  1. SET talk OFF
  2. erase
  3. *** set up the string macros
  4. DO string
  5. use jour
  6.  
  7. *get the range of memory and string patter
  8. INPUT "current byte" TO byte
  9. INPUT "last byte" TO last
  10. ACCEPT "string " TO string
  11. *move to the beginning of the string
  12. &firstchar
  13. DO WHILE byte <= last
  14.   IF chr(peek(byte)) = &character
  15.     * the current byte matches the first char of the string
  16.     STORE t TO match
  17.     * remember the address of the first byte to match
  18.     STORE byte TO firstmatch
  19.     *move to the next byte and char
  20.     STORE byte +1 TO byte
  21.     &nextchar
  22.  
  23.     *stop at the end of the string or when the matching fails
  24.     DO WHILE .not. &endstring .AND. match
  25.       IF chr(peek(byte)) <> &character
  26.         *the match failed
  27.         STORE f TO match
  28.       ELSE
  29.         &nextchar
  30.         STORE byte +1 TO byte
  31.       ENDIF chr(peek(byte)) <> &character 
  32.     ENDDO WHILE .not. sendstring .AND. match 
  33.     IF &endstring
  34.       * the entire string was matched
  35.       ? " I found a match for &string at" , firstmatch
  36.     ELSE
  37.       *the match failed move back and keep looking
  38.       STORE firstmatch TO byte
  39.     ENDIF &endstring 
  40.     *get ready to start looking for another match
  41.     &firstchar
  42.   ENDIF chr(peek(byte)) = &char 
  43.   STORE byte +1 TO byte
  44. @ 2,50 say "byte = "
  45. @ 2,60 say byte
  46. @ 3,50 say "last = "
  47. @ 3,60 say last
  48. ENDDO WHILE byte <= last 
  49. *cleanup
  50. RELEASE byte,lastbyte,string,firstmatch,match
  51. SET talk ON
  52. ***************************************************************
  53. ***************************************************************
  54. ***************************************************************
  55. ***************************************************************
  56.