[comp.sys.mac.hypercard] Appending to File From HyperCard

Douglas.Welch@p7.f823.n102.z1.FIDONET.ORG (Douglas Welch) (04/28/90)

Help !

Does anyone know how to append to a file from HyperCard.  I have
a networked log file I need to write to.

Thanks


Doug 

--  
Douglas Welch via cmhGate - Net 226 fido<=>uucp gateway Col, OH
UUCP: ...!osu-cis!n8emr!cmhgate!102!823.7!Douglas.Welch
INET: Douglas.Welch@p7.f823.n102.z1.FIDONET.ORG

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (05/07/90)

In article <51561.2643C2C1@cmhgate.FIDONET.ORG>
Douglas.Welch@p7.f823.n102.z1.FIDONET.ORG (Douglas Welch) writes:
>Does anyone know how to append to a file from HyperCard.  I have
>a networked log file I need to write to.

The following will append to the file "foo":

  open file "foo"
  read from file "foo" until empty  -- reads to end of file
  write myStuff to file "foo"
  close file "foo"

HyperCard's pointer into the file, used for reading and writing, is
always set to the last byte (character) read. It is set initially to
0 when the file is opened.
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |  AppleLink: SQA.TEST

stadler@Apple.COM (Andy Stadler) (05/10/90)

In article <40773@apple.Apple.COM> jdevoto@Apple.COM (Jeanne A. E. DeVoto)
 writes:
>
>The following will append to the file "foo":
>
>  open file "foo"
>  read from file "foo" until empty  -- reads to end of file
>  write myStuff to file "foo"
>  close file "foo"
>

Possible problem here:  HyperTalk's file read and write code has a (memory here,
don't quote my numbers) 16k file buffer size.  If you are attempting to skip
over existing text, this MAY not work when the file has more than 16k in it.

In other words, "read from xx until yy" really means "read from xx until yy
OR 16k of text read in".

This factoid presented to you from memory.  Please test before believing me.

--Andy    stadler@apple.com

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (05/10/90)

In article <40852@apple.Apple.COM> stadler@Apple.COM (Andy Stadler) writes:
>In article <40773@apple.Apple.COM> jdevoto@Apple.COM (Jeanne A. E. DeVoto)
> writes:
>>The following will append to the file "foo":
>>
>>  open file "foo"
>>  read from file "foo" until empty  -- reads to end of file
>>  write myStuff to file "foo"
>>  close file "foo"
>
>Possible problem here: HyperTalk's file read and write code has a (memory here,
>don't quote my numbers) 16k file buffer size.  If you are attempting to skip
>over existing text, this MAY not work when the file has more than 16k in it.
>
>In other words, "read from xx until yy" really means "read from xx until yy
>OR 16k of text read in".

Ooops. Quite correct. The following should ensure no problems when working
with files > 16K:

    open file "foo"
    repeat
      read from file "foo" until empty
      if it is empty then exit repeat
    end repeat
    write myStuff to file "foo"
    close file "foo"

Sorry, everybody. I've been beta testing the Caffeine Manager, and I
think it has damaged me :-).
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |  AppleLink: SQA.TEST