>On 18/9/00 4:45 pm, James Parker <[EMAIL PROTECTED]> wrote:
>> I'm reading a binary file a character at a time and looking for the
>> end-of-file marker so I know when to stop reading but the read terminates
>> before the entire file is read.  There seems to be an eof marker in the
>> file that is not at the end of the file.  CharToNum(EOF) returns a 4
>> which could appear at places other than the end of the file, right?
>> Is the following correct?
>> repeat forever
>> read from file sourcefile for 1 character
>> if the result is "eof" then exit repeat
>> put it into var1
>> end repeat
>I'm not quite sure why you want to do this, why not:
>read from file tSourceFile until eof

Thanks for your prompt reply, Kevin.

This is how I started reading files but discovered that when I read large 
files this way it hangs the MetaCard application.

>If you really do want to read char by char for some reason, you need to
>alter line 3 above to be:
>if it is eof then exit repeat
>Eof is a constant so can't be put in quotes.

The reason I did it this way is that the MetaCard documentation for 
result says 'Returns a string describing the status of the last find, go, 
open, send, or file operation command.' and for read it says that 'The 
result will be set to the string eof when an end-of-file was encountered 
during the read, or to an error message if some other error occured.  An 
empty result indicates a successful read.'

>Note that reading and writing to files is (except in a few special cases)
>generally easiest done with the URL commands.  E.g.:
>put url ("binfile:"&tSourceFile) into tVariable

Let me give this a try and see what happens.

>> Thanks,
>> Jim Parker
>Kevin Miller <[EMAIL PROTECTED]> <http://www.runrev.com/>
>Runtime Revolution Limited (formerly Cross Worlds Computing).
>Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.
>Archives: http://www.mail-archive.com/metacard%40lists.best.com/
>Info: http://www.xworlds.com/metacard/mailinglist.htm
>Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to