Hi Charles,
on Tue, 16 May 2006 10:48:15 +0200, you charleshixsn@earthlink.net wrote:
Klaus D. Witzel wrote:
You forgot to tell us a) SmalltalkImage current platformName b) fil lineEndConvention "after fil was opened" c) fil detectLineEndConvention "before the first nextLine"
Note that detectLineEndConvention scans only the first (LookAheadCount = 2048) characters.
OK, I've modified the code to include the detectLineEndConvention, thus:
| fil lin n | fil := FileStream fileNamed: 'aising/data/technologies.csv' . fil detectLineEndConvention. "fil defaultToLF." Transcript cr; show: 'LineEndConvention = '; show: fil lineEndConvention. fil position: 0. n := 0. [fil atEnd] whileFalse: [ lin := fil nextLine. n := n + 1. Transcript cr; show: 'lin '; show: n; show: ' = '; show: lin. ]. Transcript cr; show: 'normal end after '; show: n; show: ' lines'.
this causes the printout to begin:
LineEndConvention = nil lin 1 = 'technology' 'id' 'name' 'cost1' 'cost2' 'cost3' 'pre1' 'pre2' 'pre3' 'danger' 'typeName' 'typeValue' 1 'Autonomous Vehicles' 40000 1000 0 27 16 0 0 0 ... normal end after 1 lines
as it did before.
Please! Nobody here can see results when you don't print them and copy them into your next posting! !! Please insert the following code just after open:
Transcript cr; show: 'detectLineEndConvention = '; show: fil detectLineEndConvention.
Linux Squeak3.8-6665full.image That's true, but it's a guess at what you're asking for, because I don't understand the request for "SmalltalkImage current platformName ". Squeak-3.8-6665-i686-pc-linux-gnu-3.7.7.tar.gz is the file I started from.
This is Smalltalk jargon, when asked do the following a) copy and paste SmalltalkImage current platformName into a workspace b) select the pasted text c) do a print-it from the context menu d) copy&paste the result text into your next posting
The file lines end with an LF (i.e. 0x0a), as examined with a hex editor. Since all lines end with the same character, 2048 is plenty. (FWIW, the entire file is only 0x97B bytes long. It's terminated by an ordinary 0x0A, with no special markings.)
Also, I didn't "forget" to do fil detectLineEndConvention. I didn't know I was supposed to do it.
This was only for me to find out what's going wrong. So, what does fil detectLineEndConvention print?
I'm still not sure, since it doesn't seem to make any difference.
It was not supposed to make a difference, I just wanted to know what that prints.
/Klaus
I do notice the difference with this method however. With a prior approach when I did position: 0 I got a "primitive method throws an error" message, whereas with this the line end convention is just set to nil. Something is clearly wrong, as it should be LF, but attempting to coerce it into LF just throws an error: Multi-byte stream does not understand method defaultToLF, which is weird, as I can see that method in the class when I look. I copied the method name with a copy and paste from the MultiByteFileStream class into the workspace, so I know I didn't misspell it.