Could some kind soul give me a little hand up with this very simple task that is none the less baffling me:
Could you show me a code snippet that will allow me to:
Open an existing file for reading Open a new file for writing Read the input file a line at a time Write the line into the output file
I'm lost trying to locate this in the myriad of classes.
Thanks very much and sorry to bother you all with such a mundane question.
Randy Siler Coordinator, CIDR Computing Center for Instructional Development & Research 396 Bagley Hall, BOX 351725 VOICE: 206/543-0751 UNIVERSITY OF WASHINGTON FAX: 206/685-1213 SEATTLE, WA 98195-3050 EMAIL: siler@cidr.washington.edu
Could some kind soul give me a little hand up with this very simple task that is none the less baffling me:
Could you show me a code snippet that will allow me to:
Open an existing file for reading Open a new file for writing Read the input file a line at a time Write the line into the output file
| fileIn fileOut aLine | fileIn := FileStream fileNamed: 'fred.txt'. fileOut := FileStream fileNamed: 'wilma.txt'. [fileIn atEnd] whileFalse: [aLine := fileIn upTo: (Character cr). fileOut nextPutAll: aLine; cr.].
I didn't try it, but I think it's about right.
Mark
-------------------------- Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280 (404) 894-5618 : Fax (404) 894-0673 : guzdial@cc.gatech.edu http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html
I have only recently started becoming familiar with Squeak and I am excited by what I understand is happening in the Squeak community. My knowledge of Smalltalk is quite limited at the moment and I want to learn more. I have often wondered why Smalltalk hasn't become more popular than it is while Java and C++ seem to be taking the world by storm.
Could some other kind soul(s) guide me as to the most efficient route to getting up to speed with both Squeak and Smalltalk? I have found the Squeak home page, www resources, ftp resources etc. and have downloaded and run Squeak 2.2 on my Mac, however there is a lot to digest all at once. Some direction as to priority might be helpful.
Also, is there an easy way to post an indented listing of the complete Squeak class structure to a file for printing? I feel it would be helpful to see a short form of all that is available in the environment and how it is organized.
Would anyone care to comment on a comparison between Perl and Squeak? For what purposes would the use of each be most suitable?
Thanks for any help. Ken
___________________________________________________________________ Ken G. Brown, BscEE, PEng. email kbrown@tnc.com Box 3973 Phone: 403.986.9097 Leduc, Alberta, Canada T9E 6M8 Fax: 403.986.5299
"Ken G. Brown" wrote:
...I have often wondered why Smalltalk hasn't become more popular than it is while Java and C++ seem to be taking the world by storm....
Because Smalltalk embodies a relatively purist approach to computing; the "mob" tends to prefer more compromises, such as Java or C++. Note how other purist approaches to computing (Prolog, Lisp, Eiffel) tend to not be wildly accept either. One of the funny quirks of human nature. :)
-- Travis Griggs Key Technology tgriggs@keyww.com Member, Fraven Skreiggs Software Collective Status Quo Is Your Enemy
Ken G. Brown wrote:
Also, is there an easy way to post an indented listing of the complete Squeak class structure to a file for printing? I feel it would be helpful to see a short form of all that is available in the environment and how it is organized.
Open up a "System Browser", select "Kernel-Objects", select class Object, pop up the menu and select "hierarchy" - this will create exactly what you want. To get it to a file - scroll to the end of the text, place mouse pointer after all the text and double-click, this will select all the hierarchy text, which you can then copy-and-paste to your favorite text editor.
-- Dwight
Or you can just evaluate:
(FileStream newFileNamed: 'hierarchySqueak2.2.txt') nextPutAll: Object printHierarchy; close
To tell the truth though, I always do it the WIMPy way myself :-).
-- Dwight
Dwight Hughes wrote:
Ken G. Brown wrote:
Also, is there an easy way to post an indented listing of the complete Squeak class structure to a file for printing? I feel it would be helpful to see a short form of all that is available in the environment and how it is organized.
Open up a "System Browser", select "Kernel-Objects", select class Object, pop up the menu and select "hierarchy" - this will create exactly what you want. To get it to a file - scroll to the end of the text, place mouse pointer after all the text and double-click, this will select all the hierarchy text, which you can then copy-and-paste to your favorite text editor.
Thanks for the tip; I cut/pasted it into my "old system workspace" that I keep transferring to the new images because of cool tidbits like this. Odds are I'll keep using the browser, but it's still a good sample when I need to remember how to automagically dump something to a file.
Perhaps a cleaned up version of the system workspace could be restored to the base image? I know it's taught this newby a lot.
William
Dwight Hughes wrote:
Or you can just evaluate:
(FileStream newFileNamed: 'hierarchySqueak2.2.txt') nextPutAll: Object printHierarchy; close
To tell the truth though, I always do it the WIMPy way myself :-).
-- Dwight
Dwight Hughes wrote:
Ken G. Brown wrote:
Also, is there an easy way to post an indented listing of the complete Squeak class structure to a file for printing? I feel it would be helpful to see a short form of all that is available in the environment and how it is organized.
Open up a "System Browser", select "Kernel-Objects", select class Object, pop up the menu and select "hierarchy" - this will create exactly what you want. To get it to a file - scroll to the end of the text, place mouse pointer after all the text and double-click, this will select all the hierarchy text, which you can then copy-and-paste to your favorite text editor.
Ken G. Brown wrote:
<<snip>>
Would anyone care to comment on a comparison between Perl and Squeak? For what purposes would the use of each be most suitable?
The two are pretty different. Perl is a system-side scripting language used (almost?) exclusively for Web-centric scripting work. Its real strength is in regular expression parsing but it is a highly flexible language. It is not, however, object-oriented, it runs on the server (though there are versions that are implemented on the browser, not yet in very widespread use), and is not well suited to things like creating UIs, building full-blown applications, or other things for which Smalltalk/Squeak are ideally suited.
Comparing the two really is a case of apples vs. oranges.
squeak-dev@lists.squeakfoundation.org