[vwnc] Newbie question on files in Smalltalk

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Newbie question on files in Smalltalk

Mustafa Al masri
Hi there,
I'm a new developer in Smalltalk. Can someone tell me how I can access
and read a file on disk?

thanks,
Mustafa
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Newbie question on files in Smalltalk

Rick Flower
Try the Cincom tutorial :

http://www.cincomsmalltalk.com/tutorials/version7/tutorial1/weblogstats4.htm

On Sep 14, 2008, at 9:06 AM, Mustafa Al masri wrote:

> Hi there,
> I'm a new developer in Smalltalk. Can someone tell me how I can access
> and read a file on disk?
>
> thanks,
> Mustafa
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Newbie question on files in Smalltalk

Janko Mivšek
In reply to this post by Mustafa Al masri
Mustafa Al masri wrote:

> I'm a new developer in Smalltalk. Can someone tell me how I can access
> and read a file on disk?

Hi Mustafa, welcome to Smalltalk!

Here is simple example to read text file to Transcript:

| stream |
[stream := 'my.file' asFilename readStream.
[stream atEnd] whileFalse:
   [ch := stream next.
   Transcript show: ch] ]
        ensure: [stream close]


Best regards
Janko

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Newbie question on files in Smalltalk

Andres Valloud-3
In reply to this post by Mustafa Al masri
Mustafa,

You can try something along these lines.

filename := 'c:\something.txt' asFilename.
readStream := filename readStream.
[
  [readStream atEnd] whileFalse:
    [
      "do something with the stream"
    ]
] ensure: [readStream close]


Hope this helps,
Andres.


Mustafa Al masri wrote:

> Hi there,
> I'm a new developer in Smalltalk. Can someone tell me how I can access
> and read a file on disk?
>
> thanks,
> Mustafa
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>  

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Newbie question on files in Smalltalk

Claus Kick
In reply to this post by Mustafa Al masri
Mustafa Al masri wrote:
> Hi there,
> I'm a new developer in Smalltalk. Can someone tell me how I can access
> and read a file on disk?

Hello Mustafa,

welcome in the wonderful world of Smalltalk!


Have a look at the class Filename.

You can do something like

Filename fromRootComponent: 'C:\test.txt'.

This either creates a Filename object on the existing file or a new
Filename object.

Then you can send for instance
contentsOfEntireFile
to the Filename object and you will receive the complete contents of the
file.

For a binary file, you need to send contentsOfEntireBinaryFile to it.

Hope this helps and if you have any further questions, please do not
hesitate to ask. Remember: there are no stupid questions!

Best Regards,

Claus
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Newbie question on files in Smalltalk

Mark Roberts
In reply to this post by Mustafa Al masri
At 01:06 AM 9/15/2008, Mustafa Al masri wrote:
>I'm a new developer in Smalltalk. Can someone tell me how I can access
>and read a file on disk?

You can find fairly good documentation on files in chapter 13 of the
Application Developer's Guide.

Look at AppDevGuide.pdf in the /doc subdirectory of your VisualWorks
installation.

Cheers,

M. Roberts
Cincom Systems, Inc.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc