On Mon, 18 Sep 2000, James Parker wrote:

> >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.

How large were the files, and on what platform?  You should be able to
read just about anything on a Win32 or UNIX systems, but reading files
larger than a few MB on a Mac is probably not a good idea unless you
have a large amount of RAM.

> >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.'

You did the right thing.  When you don't want to put EOF in quotes is
when you're passing it to the read command (e.g., "read from file x
until eof").

> >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.

This is functionally equivalent to "read until eof", it just saves a
couple of lines of script for opening and closing the file.  Same
restrictions apply to the hardware/OS, though: You should only do this
if you're sure that there's enough virtual memory available on the
target system.
  Regards,
    Scott

> >Regards,
> >
> >Kevin
> >
> >> 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.
> 

********************************************************
Scott Raney  [EMAIL PROTECTED]  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...


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