Usually with my output I am writing it to the Transcript with...
Transcript show:
How does one write the output to a file instead?
You want to use a FileStream
See this link describing FileStreams
Excerpt below:
* for reading:
aStream := FileStream readonlyFileNamed:aFilenameString
* to read/write an existing file:
aStream := FileStream oldFileNamed:aFilenameString
* to create a new file for writing:
aStream := FileStream newFileNamed:aFilenameString
The above was the internal low level instance creation protocol, which is somewhat politically incorrect to use. For portability, please use the companion class Filename to create fileStreams:
* for reading:
aStream := aFilenameString asFilename readStream
* to read/write an existing file:
aStream := aFilenameString asFilename readWriteStream
* to create a new file for writing:
aStream := aFilenameString asFilename writeStream
* to append to an existing file:
aStream := aFilenameString asFilename appendingWriteStream
| fileName aStream |
fileName := (Filename named: 'stream.st').
aStream := fileName readAppendStream.
aStream nextPutAll: 'What is the best class I have ever taken?'.
aStream cr.
aStream flush.
aStream nextPutAll: 'It is the VisualWorks Intro class!'.
aStream close.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With