I'm using Director 6 so I can't use dot syntax  :(

Allow me to get a little more detailed.

FileIO obviously doesn't overwrite an entire text file
when it writes to a file, it just writes from char a to char b.
If there are more characters already in the text file beyond
char b, they remain untouched.

I have a linear list I am saving to a text file.
I am converting the linear list to a string and removing
the brackets and quotes.  Let's say the end result is a
string 100 characters long.

I write the 100 character long string to a text file.

Now, in one case, the string is 101 characters long, and
it writes that to the text file.  Now the text file is 101
characters long.

If I write my 100 character long string to that text file,
it only overwrites the first 100 characters of the text
file, leaving character 101 there.  The next time I read
that file, it reads the last item in the list with a 0
at the end of it, which effectively breaks my code.

I tried to add a space to the end of the string to overwrite
the trailing zero, but when it wrote 3110 it wrote "3110 "
which added 2 spaces to the overall length. Same problem.

I've decided that the only way to really handle this is to
do a short repeat where it checks to see if the last char
of the string is a space, and if so, delete it.  This should
solve the problem, in theory.  If you have any other ideas,
please let me know.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Kerry Thompson
> Sent: Friday, August 10, 2001 1:12 AM
> To: [EMAIL PROTECTED]
> Subject: Re: <lingo-l> File IO - how do I erase text in a file?
> 
> 
> 
> >Is there  Some way to just delete
> >the last char of the text file each time it opens
> >it to save and then write to it
> 
> How about:
> 
> theText = readFile (theFile)
> delete theText.char[theText.length]
> writeString (theFile, theText)
> 
> Does that do what you want? I got a little lost in the part about 
> the 4 and 
> the 3 and 0 and the 4th 0 of the third minor seventh.
> 
> Cordially,
> 
> Kerry Thompson
> 
> 
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> 


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to