Hi,
I wanted yesterday to save data into a text file from a loop, one line at a time, using TextOutputStream.Append.
At first, I totally does not understand how to use it. My first attempt does not works at all.
Here’s an idea of the used code
Dim FolderItem and TextOutputStream
Create instances of FolderItem and TextOutputStream
In a loop:
a. Read one line from the source text file
b. Do some trickery to that line (and store it in OneLine)
c. Append OneLine in target text file
I had constant crash at the .Append line. The file was created, but empty at crash time.
The target text file was filed with the first line correctly modified when the IDE application quits.
Then, I checked:
http://documentation.xojo.com/index.php/TextOutputStream.Append
I removed the Dim / Create instance for the target text file,
copy / paste the example from docs,
and it worked.
Then, I commented out that code, try back my own and found it working reliabily. *
Why ?
That line in a loop looks to me like no-no. I cannot understand that line executed, say 100, 200 , 10,000 times
Dim t as TextOutputStream = TextOutputStream.Append(f)
What is your feeling ?
- It happens to me too using AppleScript (with the Script Editor): the script worked fine, but a copy/paste was wrong (and it still works !) Incredible.