Hmm, yes I think. Look, this is the example code I've modified:
`GameCrypt demonstration file
`First of all we need to open a protected file and give it a key. We shall use "gamecrypt"
`as our key. We will need this key to get our data back out of the file.
`We shall use "data.txt" as our file name and the function gives us back a number which
`we can use to write to our protected file.
handle = OPEN PROTECTED FILE WRITE("data.txt","gamecrypt")
`Now we will write some data to our file.
`Lets write a string
WRITE PROTECTED STRING handle,"The quick brown fox jumps over the lazy dog."
`Lets write an integer
WRITE PROTECTED INT handle,42
`Lets write a float
WRITE PROTECTED FLOAT handle,3.1415
`Now close the file we have written
CLOSE PROTECTED FILE handle
rem JUST WHAT I'VE ADDED
suspend for key
`Now we will verify the contents of the file. This is useful to make sure nobody has
`altered the file in anyway. If a different key is used then verification will fail.
result=VERIFY PROTECTED FILE("data.txt","gamecrypt")
if result=0
print "The file has been altered by outside means. Verification failed"
else
print "The file has not been altered by outside means. Verification SUCCESS"
endif
`Now we will open the file, but for reading. Note that we must use the same key
`as we used to write it or our data will be garbled.
handle=OPEN PROTECTED FILE READ("data.txt","gamecrypt")
`The data must be read out of the file in the order that it was written to the file.
`Lets get out string back and display it
PRINT READ PROTECTED STRING(handle)
`Lets get our int back and display it
PRINT READ PROTECTED INT(handle)
`Lets get our float back and display it
PRINT READ PROTECTED FLOAT(handle)
`Suspend for key so we can see the results of the test
SUSPEND FOR KEY
`Close the protected file
CLOSE PROTECTED FILE handle
So, what I've done is:
1)Execute the above code
2)When the program wait for you to press a key, open the data.txt
file in notepad and randomly edit something
3)Save the edited data.txt
4)Press a key to continue the program and then the error should happen...
[edit] Maybe it's because the data.txt file is altered so the READ PROTECTED STRING command create an error...