RE: lingo-l File IO - how do I erase text in a file? SOLVED...

2001-08-10 Thread pranavn


Gosh! Wouldn't it just be easier to delete the file and then rewriting to
it rather than going through all those repeats and stuff?

Cordially,
Pranav Negandhi
New Media Applications.
Learnet India Limited, Mumbai.
Phone: 91-22-859 8042 Ext: 410



snip
I figured out a workaround, clunky as it may be.

---
set gTheWriteText = removeQuotes(gTheWriteText)

  if the last item of gTheWriteText =  3110 then
nothing
  else
put SPACE after gTheWriteText
  end if

on removeQuotes dataString
  repeat with a = 1 to the number of chars in dataString
if char a of dataString = QUOTE then delete char a of dataString
  end repeat
.
-Steven
snip





[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!]




RE: lingo-l File IO - how do I erase text in a file? SOLVED...

2001-08-10 Thread Steven Sacks

 Gosh! Wouldn't it just be easier to delete the file and then rewriting to
 it rather than going through all those repeats and stuff?

Easier?  Maybe, but as much fun?  I say thee nay!  =)

Deleting the file requires recreating the file and then writing
to the file again.  What's easier?  Running a repeat loop, or
doing complex file management?  The repeat loop won't fail, whereas
the File IO might act up at any time.  Best to minimize the work
the computer has to do (in this case a 90MHz Pentium I).  I might
be a victim of superstition here, but it feels like a safer bet
to run a repeat loop than have to recreate the file over and over.

I am saving CONSTANTLY to this file.  Deleting, creating, and
writing to a file over and over doesn't seem a good idea. I'm
thinking that after thousands of times of doing that, the hard
drive would start losing sectors and require defragging.

Of course, I'm no hard drive/OS tech, so I'm just guessing.
At any rate, it works now, so all is good.

Thanks,
Steven 


[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!]




RE: lingo-l File IO - how do I erase text in a file?

2001-08-10 Thread Mark R. Jonkman

Hi Kerry

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

That's the problem with you exBostonians.. you lose a little
hair and you get totally befuddled by by the 4th 0 of the
third minor seventh. you should take up hockey as a
specator sport... it might help clear up your mind a bit ;-)

mark


[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!]




RE: lingo-l File IO - how do I erase text in a file?

2001-08-10 Thread Mark R. Jonkman

Hi Steven

did you try to do the following

set someFile = new( Xtra FileIO)
errorCode = openFile(someFile, FilePath, 0)
errorCode = delete someFile 
errorCode = closeFile( someFile )
set someFile = 0

it might work just a wild stab in the dark

Sincerely
Mark R. Jonkman

[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!]




RE: lingo-l File IO - how do I erase text in a file? SOLVED...

2001-08-10 Thread pranavn


If you really have to do this stuff often, and your strings aren't too long
(64k, if I remember correctly) you can try the setPref command.

Cordially,
Pranav Negandhi
New Media Applications.
Learnet India Limited, Mumbai.
Phone: 91-22-859 8042 Ext: 410



snip
Deleting the file requires recreating the file and then writing
to the file again.  What's easier?  Running a repeat loop, or
doing complex file management?  The repeat loop won't fail, whereas
the File IO might act up at any time.  Best to minimize the work
the computer has to do (in this case a 90MHz Pentium I).  I might
be a victim of superstition here, but it feels like a safer bet
to run a repeat loop than have to recreate the file over and over.

I am saving CONSTANTLY to this file.  Deleting, creating, and
writing to a file over and over doesn't seem a good idea. I'm
thinking that after thousands of times of doing that, the hard
drive would start losing sectors and require defragging.
snip





[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!]




Re: lingo-l File IO - how do I erase text in a file?

2001-08-09 Thread Kerry Thompson


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!]




RE: lingo-l File IO - how do I erase text in a file?

2001-08-09 Thread Steven Sacks

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!]




RE: lingo-l File IO - how do I erase text in a file?

2001-08-09 Thread Sean Wilson

 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've had the same problem. The only workaround I could come up with was to
delete the contents and write it out again amended. Some delete functions
would be really useful - other than just the entire contents; which is all
it seems to provide.

Could you use BudAPI's ini functions instead?


[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!]




RE: lingo-l File IO - how do I erase text in a file? SOLVED...

2001-08-09 Thread Steven Sacks

sorta...

I figured out a workaround, clunky as it may be.

---
set gTheWriteText = removeQuotes(gTheWriteText)

  if the last item of gTheWriteText =  3110 then
nothing
  else
put SPACE after gTheWriteText
  end if

on removeQuotes dataString
  repeat with a = 1 to the number of chars in dataString
if char a of dataString = QUOTE then delete char a of dataString
  end repeat
  return dataString
end
---

This puts a space over the 0 where the 3110 would be.
But now the last item in the list when it brings it back in
will be 321 .

So, I just delete the last char of dataString if it = SPACE
before putting quotes back into the list.

on replaceQuotes dataString
  if the last char of dataString = SPACE then delete the last char of
dataString
  repeat with a = 1 to the number of items of dataString
if char 1 of item a of dataString = SPACE then delete char 1 of item a
of dataString
put QUOTE before item a of dataString
put QUOTE after item a of dataString
  end repeat
  return dataString
end

I just realized, though, that I could have solved that problem
differently by just saying string(value(x)) since they are numbers.

I hope this helps somebody else.  You can retrieve the number of
characters in a file using FileIO, so you can easily add a bunch
of spaces to the end of your string you are writing and delete
them all when you read them:

repeat while the last char of dataString = SPACE
  delete the last char of dataString
end repeat

-Steven



[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!]