home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
dbadv.zip
/
PEEKFIND.PRG
< prev
next >
Wrap
Text File
|
1986-02-25
|
2KB
|
56 lines
SET talk OFF
erase
*** set up the string macros
DO string
use jour
*get the range of memory and string patter
INPUT "current byte" TO byte
INPUT "last byte" TO last
ACCEPT "string " TO string
*move to the beginning of the string
&firstchar
DO WHILE byte <= last
IF chr(peek(byte)) = &character
* the current byte matches the first char of the string
STORE t TO match
* remember the address of the first byte to match
STORE byte TO firstmatch
*move to the next byte and char
STORE byte +1 TO byte
&nextchar
*stop at the end of the string or when the matching fails
DO WHILE .not. &endstring .AND. match
IF chr(peek(byte)) <> &character
*the match failed
STORE f TO match
ELSE
&nextchar
STORE byte +1 TO byte
ENDIF chr(peek(byte)) <> &character
ENDDO WHILE .not. sendstring .AND. match
IF &endstring
* the entire string was matched
? " I found a match for &string at" , firstmatch
ELSE
*the match failed move back and keep looking
STORE firstmatch TO byte
ENDIF &endstring
*get ready to start looking for another match
&firstchar
ENDIF chr(peek(byte)) = &char
STORE byte +1 TO byte
@ 2,50 say "byte = "
@ 2,60 say byte
@ 3,50 say "last = "
@ 3,60 say last
ENDDO WHILE byte <= last
*cleanup
RELEASE byte,lastbyte,string,firstmatch,match
SET talk ON
***************************************************************
***************************************************************
***************************************************************
***************************************************************