Problems with CrLfFileStream

Jimmie Houchin jhouchin at texoma.net
Sun Mar 10 01:13:02 UTC 2002


Hello all,
I am finally prioritizing my time and digging in to learn 
Squeak/Smalltalk. [:)]

I am trying to learn about reading/writing files, etc.
As a part of learning I am doing some things I've done in Python.

I've been playing with the CrLfFileStream to read an existing file line 
by line and then write a new identical file line by line. Here is the 
code I've entered into the Workspace. My apologies if the code isn't 
formatted properly. I haven't learned that yet. [:)]

file1 := CrLfFileStream new.
file1 open: 'TestFile' forWrite: false.
file2 := CrLfFileStream new.
file2 open: 'NewTestFile' forWrite: true.

Transcript show: [
[file1 atEnd] whileFalse:
[file2 nextPutAll: file1 nextLine.
 file2 nextPutAll: file1 "DoSomethingHereToInsertProperLineEnds"].
 file2 flush.
 file2 close.
 file1 close.] timeToRun.

If I've entered the code identically on my PC (work) and Mac (home) I've 
gotten two different problems.

At work on a WinME PC it worked. My problem was I could not get it to 
insert lineEndings properly. Everything I tried just inserted a string 
of "crlf" into the text and it was all on one line.
I tried "file1 detectLineEndConvention", "CrLfFileStream 
LineEndDefault", "file1 lineEndConvention", all with the same results a 
string of "crlf". [:(]

On my PC running 3.0 final no updates, CrLfFileStream didn't have a 
lineEndConvention accessor, if I remember correctly. So I wrote one. 
Didn't help. The Mac had one.

I decided to continue experimenting when I got home.
However, on the Mac updated to 4798 it won't open/create (it didn't 
exist) the "NewTestFile".
Consequently I get errors.

I am sure they are simple problems and I'm just missing something.
The code above was copied from my Mac. As far as I remember it was 
similar on the PC.

Thanks for any help.

Jimmie Houchin


More information about the Squeak-dev mailing list