Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!zombie.ncsc.mil!news.duke.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!ix.netcom.com!netcom.com!rfenney.slip.netcom.com!user
From: rfenney@netcom.com (Robert J. Fenney)
Subject: Re: how to read a file in smalltalk
Message-ID: <rfenney-150395203640@rfenney.slip.netcom.com>
Followup-To: comp.lang.smalltalk
Sender: netnews@mork.netcom.com
Organization: FenTek
References: <3k5kk5$3rb@panix.com>
Date: Thu, 16 Mar 1995 04:42:12 GMT
Lines: 49

In article <3k5kk5$3rb@panix.com>, pma@panix.com (Patrick Ma) wrote:

> I am trying to read in a text file and display it in a TextPane using Smalltalk/V. I 
> read in the tutorial that I can use input := File pathName: 'myfile.txt'. However, 
> this assumes that myfile is in the current directory.  So, I thought I would try 
> using a windows standard open dialog box to get a file.   This way, I am not limited 
> to files in my current directory. I used
> 
> 	input := FileDialog new openFile file.
> 
> Now, input contains the whole pathname + filename.  My problem is how do I create a 
> filestream out of input.  I used 
> 
> 	file := FileStream on: input
> 
> thinking that I will create an instance of FileStream so that I can do something 
> like [file atEnd]
> 	ifFalse [read it in] (as you can see I am not well verse in ST syntax)
> 
> Well, all I got from the above is a Walkback.  Debug says ST does not understand 
> something in setLimits.  It was something like not understanding 
> readbuffer:atposition:.  Anyone want to help this beginner out? Thanks in advance. 
> 
> 
> -=> article created by NewsEditor and posted by inews <=-
> Patrick Ma  
>   pma@panix.com
>     74030.2531@compuserve.com

I was able to read a file by:

myFile := fileStream chooseFile.
myList := myFile NextObject.
MyFile close.

This code allowed be to open and read a list. pritty neat!

I know this is not ST/V but at least it works on my MAC. :)


In all seriousness I am appalled at the lack of documentation for
Smalltalk. I have spent almost 1K on every book I could find and they where
almost useless! I keep rereading them in hopes that I will gleem some piece
of information that will prove that I was not crazy for buying them. Anyway
I know how you feel and can only say hangin there! Smalltalk IS WORTH IT!!!



Robert
