I'm writing a simple program using Squeak for a Principles of Programming Languages assignment. Everything seems to be going pretty good. I'm basically writing a small script in the Workspace window and then submitting that code. Whenever I go to Yellow->More->Save Contents to file the file that is produced has a bunch of ^M's in it instead of carriage returns. So, the code doesn't look very pretty. Is this because of some DOS formatting or some such? How can I alleviate this problem? Also, is there a way to "Quick-Save" this file so I don't have to type in its filename each time? (It defaults to Workspace.text).
I'm using Squeak under Linux on an i686.
Thanks in advance,
Jeff "Shippy" Shipman E-Mail: shippy@nmt.edu Computer Science Major ICQ: 1786493 New Mexico Institute of Mining and Technology Homepage: http://www.nmt.edu/~shippy
Hi Jeff,
you could run the file you get through a translator afterwards in the shell: $ cat Workspace.text | tr '\r' '\n' >myfilename
You can also change the name of the Workspace window by selecting "Change title..." from the menu that pops up when you select the little icon right of the "X" window close icon in the left part of the titlebar. The default filename is <WindowTitle>.text
But hey, this is Smalltalk: If you do a user interrupt (Alt-. [Alt-<dot>] on Windows, maybe Ctrl-. on Linux) while you are prompted for the file name, and press "Debug" in the resulting window, you can actually look at the code that does this - and change it to do what you want.
In the upper pane of the debugger, you see a stack trace. scrolling down, we note classes called "FillInTheBlank*" - we assume these are responsible for the file name dialog.
Under that, we see "TextMorphEditor(ParagraphEditor)>>saveContentsInFile", this sounds like the operation we requested. Click on it and the middle pane shows the corresponding method source.
Here you can comment out the code that appends ".text", for example, or cut out the whole prompt If you replace the "FileStream" with a "CrLfFileStream", this should take care of giving you the right CR/LF scheme for your platform.
You can then select "accept" from the menu (or do Alt-s), and select "restart", and your changed code will run.
Have fun Squeaking, Joern
Jeff Shipman shippy@nmt.edu asked...
Also, is there a way to "Quick-Save" this file so I don't have to type in its filename each time? (It defaults to Workspace.text).
Yes.
If you already have saved the file as, eg, 'Mystuff.txt', then execute...
(FileStream fileNamed: 'Mystuff.txt') edit.
This will give you a text-edit window on that file. Whenever you type cmd-s or use menu/accept, it will overwrite the contents after a simple confirm. (*)
Whenever I go to Yellow->More->Save Contents to file the file that is produced has a bunch of ^M's in it instead of carriage returns. So, the code doesn't look very pretty. Is this because of some DOS formatting or some such? How can I alleviate this problem?
I *think* that your ^M's are due to the fact that Squeak uses unadorned CR's instead of CR/LF pairs as a default for line endings. Moreover, I *think* that if you execute...
(CrLfFileStream fileNamed: 'Mystuff.txt') edit
It will store all your line endings as CR/LF pairs, and things should look right in all the other weird DOS software. I don't *know* this because I almost never use DOS or Windows, and I can't check it on my Mac.
Hope this helps
- Dan
(*) If you know the FileList, you can edit right in the fileList, and you can spawn a window on any file by choosing menu/more.../spawn in the lower pane.
squeak-dev@lists.squeakfoundation.org