Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
New Squeaker questions
Last updated at 8:28 pm UTC on 3 June 2020
mergeMe into Squeak FAQ

If you have a question to any specific aspect of Squeak and you didn't ask or didn't get an answer on the Squeak Mailing Lists feel free to add it here. Simply hit the edit button at the top, add your question, and save the page. Answered Questions should then be moved into the Squeak FAQ.
Suggested Format for Questions:

Question

Answer


Unanswered Questions:

Answered Questions:

Morphic

Files

Networking

Performance

Operating Systems

Persistence

Unclassified


Moving classes between images

Question

I just updated my Squeak to 3.7. My projects are still in the old 3.6 image. I've tried to save them to disc via the Publish option, but this seems not to export the classes, just the project setup...
How do I mark my classes as belonging to the project, so I can import them into the new image?
When I try to drag the project file onto a Squeak session, it tells me something about "Reading an instance of [classname]. What modern class should it translate to?"

Class Environment

Question

There is a class Environment, which is able to provide namespaces. Nothing seems to use it. It is a trash? Under development. Any clues to use/improved it? [Umur Ozkul]

Answer

An Environment is a space for class and global variable bindings. As such, it associates names with objects. Each class has a "home" Environment and the methods of a class will use that environment to look up global names, such as class names. A Squeak image can contain multiple Environments. They can share classes, but do not need to; each Environment can import bindings from other Environments (possibly under different names!) and export all or some of its own bindings for other Environments to see. This can be used to resolve name conflicts if two packages both provide a class with the same name: load one of the packages in another Environment, then import all the classes into the main Environment (Smalltalk globals), but with some class names changed. If you ask the classes for their names, they will respond with their original name, but you can refer to these classes in methods as if they had a different name. You could also have multiple working copies of the same package in different versions in your image, by loading the working copies in different Environments. Class extensions in shared classes are a problem though.

Outputting and Inputting Raw Objects

Question

Does Squeak have an equivalent to Java's ObjectInputStream and ObjectOutputStream classes so that raw object data can be read from and written to files?

Answer

You can use the ReferenceStream class. Here is an example:
obj := #(1 2 'hi').

out := ReferenceStream fileNamed: 'test'.
out nextPut: obj.
out close.

in := ReferenceStream fileNamed: 'test'.
newObj := in next.
in close.

"newObj now has the value #(1 2 'hi')"

In this example, the value of obj is written to a file named "test" in the image directory (you can also specify an absolute pathname if you want) and then read into newObj. AFAIK, you should not combine calls to next and nextPut: on the same stream. – Tom Plick

Multiple Inheritance

Question

How do you do multiple inheritance? This is the closest I could find: http://www.unicavia.com/Squeak/MultipleInheritanceInST80.html

Answer

Right now ( Squeak 3.4 ) Squeak is still based on single inheritance. However a project called To Traits Or Not To Traits is in the works that may offer the benefits of multiple-inheritance without the drawbacks. [3/5/2003 bkv]

Search all scrollingTextMorphs

Question

I'm using Squeak as a sort of organizer/presenter of thoughts/ideas. I have a billion little scrolling text morphs in my many projects like so many PostIt(tm) notes. My question is this: how can I search them all for a string? Am I just completely stupid? Is there something terribly obvious I'm missing?

Answer

You best choice is probably to use a BookMorph for this. It provides searching.

You can also try something like this. The question is what you want to do with the matches. This example attaches them ALL to the cursor. You may replace openInHand by something else.

(TextMorph allInstances select: [:each| 
	(each contents asString includesSubString: 'asd123')
	& each world == World "ignore embedded TextMorphs"
	]
) do: [:each| each openInHand]
Martin Drautzburg

Variable Frame-Scrolling Speeds

Question

1)Does anybody remember the early scroll method used in V286 where, with the right button pressed and moving the mouse outside the frame, variable scrolling speeds were achieved?

It seems far more simple than the current method. Particularly for older people like myself, who find the positioning of the cursor very difficult to manage. What happened to it?

Answer

V286 is not part of Squeak's ancestry - it was developed from scratch, not based on the Smalltalk-80 image. That does not mean that nothing from it could have found its way into the Squeak image, but this particular feature did not...

If somebody were to implement that feature, there would be a user interface design problem: the right mouse button is already used by Squeak, you can't simply reassign it without breaking a number of other things.

CPU Usage

Question

I loaded Squeak3.0-x86linux. It runs and looks nice, plays music, and stuff, but uses 100% CPU - even when idle! This would be fine for DOS, but makes the system rather impractical for unix. Can this be fixed?

Answer

The SqueakEyes morph uses a lot of CPU. Delete it, and your CPU usage should go down to almost nothing.

Well, there may be other reasons for a 100% CPU... see Maximum Squeak for more info.

Answer

I think, with respect, the author does not understand the total difference between Smalltalk (image based) and Unix/Linux and its poor cousin DOS (Program based ie binaries .exe .com .dll etc).

With Smalltalk, late binding keeps the CPU very busy. Things improve only when development is complete, the image is compiled into native code. The old Interpreter/Compilor struggle eh!.

All interpreters are notoriously slow when compared with Unix / Linux / DOS.

Without the interpreter we have no virtual machine, Smalltalk is after all, a virtual machine. Its plusses outweigh its minuses by a country mile.

Consider this. On my machine I have 3 minimal systems:

win95 (about 75mb, 3000 files), zipslack linux (about 80mb 9500 files ) and Squeak (26mb and 3 files). Notice the difference?

We all know that the slowest device is always the drive.

With DOS / Windows / Linux the drive light rarely go out, but with Smalltalk the drive light rarely goes on.

Smalltalk suffers if the software is poorly designed but screams ahead when the application software is well designed.

In the bad old days of "go to" programing the same problem occurred with the introduction of Virtual Memory: the CPU would go crazy, page faulting, while the mainframe was brought to a standstill. Bad s/w design!.

We solved that problem in the early 1970s with Structured Programing. Out went the goto, in came the begin block (structure).

Where program designers have learned: replacing The Flowchart for Pseudocode, System Designers are still using Entity Relationship models based on the old goto principles.

Smalltalk is starving for good designers with better design methodologies.

Remember this P. R. E. P. "PREPare Your Goals"

What does PREP mean? Sorry, you'll have to wait for the next edition.

Clue: mission statements. – jw

Answer

....I am not sure what you are trying to say in your answer. I am not sure that the person designed the apps that are consuming his CPU. I think he may be experiencing what I did: I downloaded Squeak 3.2. It ran pretty fast on my 333MHz Pentium II with 128MB RAM. Recently I downloaded 3.4. When I started it and just tried to do basic things, it was a sleeping pig by comparison. I don't really know if the 3.2 was more optimized(?).... I have heard some discussion somewhere about "stripped down" images (?) which do not have things/toys you don't need. Maybe there is something there?
I simply went back to 3.2, and decided the answer would come as I got more experience. Or when I get around to re-joining the mail list.
By the way, I got alot of Squeak questions answered by reading the Mark Guzdial book called "Squeak - Object Oriented Design w/ Multimedia Applications" I got alot of info about Smalltalk from the IBM tutorial - If you don't know much about Smalltalk, read the IBM doc first.

Socket Question

Question

Using SimpleClientSocket to connect to a server running locally. Connects ok (I can see it in the server log) but WaitForConnectionUntil returns false immediately. The code then attempts to send some data but of course nothing can be sent. What gives?

Answer

Found it myself :)
The argument given to WaitForConnectionUntil is in milliseconds, not seconds.

Question about .zip, .tar, .gz, and .cs Files

Question

I've downloaded various files for use with squeak that come in zip tar gz cs files... how do i go about making squeak aware of them?

Answer

.cs files are ChangeSets. They are mostly compressed with gzip when sent around and thus gets an extra .gz extension. From the FileList you can both decompress such files and install them. Then you can find these ChangeSets in a change sorter (check under open...).
/G�ran Krampe

GUI Interfacing

Question

Hi All,
I have had some experiance with other Smalltalks and am finding Squeak very enjoyable to work in. The one thing I have not worked out how to do is interface the classes I have created in some form of GUI environment.

I have studied 'Play with me 1' which updates common windows widgets upon user selection but cannot for the life of me fathom how it works. Is it just me or are the generic textboxes, text, selection boxes not exactly intuitive?

Thanks!
Dirk

Answer

Morphic can be used both programmatically or by "direct manipulation". This means that you really don't need a "GUI Painter" - even though there are some of those around too as extra Squeak packages. To learn I would personally start by making a UI programmatically. Try looking at existing code and do some copy paste.

Answer

I had the same problem and going through this tutorial helped: ProgrammingMorphs. Basically, you can open a Workspace, then from its menu enable "create textual references to dropped morphs" and then simply drop the objects you want to program into your workspace.

Squeak Won't Start

Question

Squeak won't start. It says "Using default visual", then it says "This visual class is not supported".

Where can I find docs that talk about getting Squeak to start?

Answer

Are you using VNC? If that is the case try starting VNC with "vncserver -cc 3" instead. Otherwise see if you can change your X configuration.
/G�ran Krampe

openInWorld Explained

Question

this code:

FileList open 

doesn't work. If I inspect result it returns a System Window, but I can't see any.

Answer

try:

FileList open openInWorld.  "if you're in Morphic"

"or"

file := FileList2 modalFileSelector.

The problem is that open just returns a window, it doesn't open the window. (nk)

Amiga Squeak?

Question

When is somebody going to port Squeak to the Amiga?

Answer

April 15, 2021, at 13:14:15 UCT
It's not too hard to do, if you know how to program in C on the Amiga. Wanna try? Announce your intention, and be sure to check out the Other Squeak ports page.

It's NOT as easy as the Authors of Squeak make it out to be. For instance, the makefile (for SAS-C) generates an executable that still has stubs for various plug-ins that supposedly are not required to get a minimum Squeak executable up & running. Someone needs to go through the build information & explicitly inform a potential Amiga porter just what source files are required (especially the plug-ins & other optional portions of Squeak). I gave up in frustration, since there are definitely more than 12 functions that have to be re-written from the Macintosh source code. Jim Steichen, jimbot@frontiernet.net

User Prompting

Question

Does anybody know of a good tutorial or explanation on menus and various ways to prompt the user? I've been to the Prompting the user page, but its not very explanatory, I can't quite get what I want out of it...

Answer

Hannes Hirzel: Yes it contains script examples. Perhaps it might be an idea that you just put in your questions in the text there. A good place to start exploring menus is to read the code of Dynamic open menu.

Binary File Splitting

Question

The following code should split a binary file of 1.6MB size into two files to move them by diskette to another computer. (binary copying)

However the StandardFileStream objects want to work with characters only. There is a class RWBinaryOrTextStream but it is not clear how to open a file with it.

fn _ (dir _ FileList2 modalFolderSelector  pathName , 
FileDirectory pathNameDelimiter asString) ,   'myFile.zip'. 
s _ (StandardFileStream new open: fn forWrite: false) binary.
out _ StandardFileStream fileNamed: (dir, 'myFile1.zip').
1000000 timesRepeat: [ out nextPut: s next].
out close.
out _ StandardFileStream fileNamed: (dir, 'myFile2.zip').
[s atEnd] whileFalse: [ out nextPut: s next].
out close.

How can this be accomplished?

Answer

nk: what's wrong with this?
| inFile inName splitSize partNumber totalBytesRemaining |
inName _ '/home/ned/x.log'.
inFile _ (StandardFileStream new open: inName forWrite: false) binary.
totalBytesRemaining _ inFile size.
splitSize _ 100000.

partNumber _ 1.
[ inFile atEnd ] whileFalse: [ | outFile bytesRemaining |
 bytesRemaining _ splitSize min: totalBytesRemaining.
 outFile _ (StandardFileStream new open: inName, partNumber asString forWrite: true) binary.
 [ bytesRemaining > 0 ] whileTrue: [ | bytes |
 bytes _ inFile next: (4096 min: bytesRemaining).
 outFile nextPutAll: bytes.
 bytesRemaining _ bytesRemaining - bytes size.
 totalBytesRemaining _ totalBytesRemaining - bytes size.
 ].
 outFile close.
 partNumber _ partNumber + 1.
]

.morph Files Question

Question

I have a previously created sketchMorph saved as a .morph, and I now wish to edit it further. Whenever I try opening it, however, it opens the file as text, which doesn't do me much good. My goal is to change a certain part of this sketch's color from within the program (no prompting or anything like replaceColor). Is there an easy way to do this?

Answer

You can open it in the file list browser. If you do a World's smallest drawing program click then you get the text file you mentioned. But if you do a Yellow button click then you get a menu with an entry like 'Open as morph'.

Multi-User Squeak Security Question

Question

I'm thinking of using Squeak in an environment where many users, some untrusted, will be able to write Squeak scripts to extend an environment contained within a single image on a server. The problem that comes to mind is that these users will have access to all sorts of nasty things, like the ability to say "SmallInteger := nil" or say, use file objects to obliterate the image. Thus, I'd like to make some classes use-only, and some classes inaccessible, from their scripts. Is there any easy way of going about this or existing functionality that may be helpful? Or do I just have to dig down into the details of the compiler? Thanks a lot.
Derrick Coetzee

Answer

safeEvaluate: aString
^nil

Seriously, it's an open problem to allow safe execution but still to leave enough power with the user to be useful. See Islands and Squeak-E towards some of the work in this area. It's a very solvable problem, but to date there has been too little effort to flesh out a full solution.


Nebraska Question

Question

How can one modify Nebraska to work with worlds other than World? I have sucessfully used Nebraska on World, and even played with shrinking World, and Nebraska all still works fine (so it's not a screen size mismatch problem). Yet when I create a world within World and try to use Nebraska to serve just that world, the client just displays a black box in the upper left corner and never displays the shared world. The Nebraska server reports a connected client, however. Anybody dealt with this one? Thanks..

CSV How-To

Question

How does Squeak read Comma-Separated Variable file formats?

Answer

File in the CSV parsing. This will give you a method on String called #csvSubstrings which will take a CSV encoded line and transform it into an array of strings. So, to read a CSV file, you could run:
|file rows|
rows _ OrderedCollection new.
file _ StandardFileStream fileNamed: 'someFileName.csv'.
file linesDo: [:line| rows addLast: line csvSubstrings].
rows inspect.

Berkeley DB From Squeak

Question

Can I do Berkeley DB from Squeak?

Answer

http://map.squeak.org/package/7e85cb48-d768-4386-8546-36495c35448b

.sit Files For Macs

Question

How do I use .sit files? Kris - NewSqueaker

Answer

.sit files are archives in the 'stuffit' format. There are utility programs for example 'AlladinExpander' for MSWindows to unpack these files.

Installing Squeak on a Mac

Question

Is it possible to install Squeak automatically, without the manual process of compilation and installation quite impossible for a unexperienced programmer like me? Using Mac OS X, each software is usually installed by a package simple to install, automatic or with few step by steps? Michel - future new Squeaker

Answer

I'm not sure where you got that information, but from what I understand (I'm a newbie Squeaker too), it should be a simple process. You should be able to download the sit file here:
ftp://st.cs.uiuc.edu/pub/Smalltalk/Squeak/3.5/mac/Squeak3.5-current-MacOS-Full.sit
Just decompress that, and you should be good to go!

Porting Squeak to FreeBSD

Question

I've just recently become interested in Squeak, and am trying to install it on my FreeBSD (4.6) box at home. Now if I use the ports, I can easily install Squeak 3.0, but when I try upgrade all the way to 3.2 my virtual machine of course needs to change, and I'm not sure how to do this.
So I gave up that approach and tried downloading the source for 3.2 and building it myself.
That, however, fails with:
In file included from /usr/home/frank/Squeak-3.2-4/platforms/unix/plugins/PseudoTTYPlugin/sqUnixPseudoTTYPlugin.c:75:
/usr/home/frank/Squeak-3.2-4/platforms/unix/plugins/PseudoTTYPlugin/openpty.h:46: #error : cannot find headers for openpty()
Error: this should not happen Error code 1
Now part of the output of the configure script is
checking for util.h... no
checking for pty.h... no
checking for stropts.h... no
checking for library containing openpty... -lutil
So it looks (judging from the content of openpty) than I need either util.h or pty.h. So what do I need to install to get them?
Hm. Upon googling, I've seen several unrelated sources talking about libutil.h...
OK, I did some hacking in openpty.h, and I made openpty.h #include libutil.h instead of #include'ing pty.h or util.h.
Am I sane in trying this? – Frank Shearar
I've installed via the port and it works well, even sound after a bit of fiddling with NAS. I have noticed one problem: mouse click actions sometimes don't occur until the mouse is moved even just one pixel.
For example - click a flap. Nothing happens until you move the mouse. The Windows and Linux versions don't exhibit this behaviour. -Geoff
(5.1-RELEASE-p10, XFree86 Version 4.3.0)

Answer

Note: The Unix port, maintained by Ian Piumarta, should install fine on FreeBSD
[3/5/2003 bkv]

Ah, as usual, less is more - as you say, you just need to install the FreeBSD squeak port, in /usr/ports/lang/squeak. – Frank Shearar

Adding a delay to TTS

Question

How do I add a delay to TTS
Speaker man say: 'hello, how are you today. What's for lunch'
The play back appears to ignore punctation marks.
thanks

Answer

this is not that easy because the synthesizer will try to queue successive commands and process them all at once. You have to trick it doing something like:

[Speaker man say: 'hello']fork. (Delay forSeconds: 2) wait. Speaker man say: 'goodbye'.

But that exact framework might not achieve what you want. If it does not work, well I'm pretty sure you can get it to work if you try similar things. That is the joy of having an interpretted environment! -Webb McDonald


Squeak on Windows without DirectX

Question

How do I make Squeak work on a Win95 machine that doesn't have DirectX?
When I tried to start Squeak, it complained about missing DLLs (opengl32.dll and dinput.dll). I found opengl32.dll at Microsoft.com, but dinput.dll seems to be a part of DirectX, and according to several magazine articles installing DirectX can do all kinds of bad things (e.g. corrupt the screen due to incompatibilities between DirectX and the video card driver), and it seems to be difficult or even impossible to deinstall DirectX if anything undesirable happens. Thus I'd prefer to not install DirectX and use Squeak without it. I couldn't find any information about how to do it, especially there seems to be no command line option -nodirectx or similar for the Win-VM. What do I have to do?

Move a window from one morphic project to another

Question

Is it possible to move a window from one morphic project to another?

Answer

It's easy. The basic operation is to re-open the window in the target project. For example, if you can get the window you want to move into an object and you know the name of the target project, do the following. {selectedWindow} is the window object. {'destination project name'} is the name of the target project.
selectedWindow openInWorld: ((Project named: 'destination project name') world)

GUI Based Answer

The first answer requires more than just newbie knowledge. An alternative solution is to open the halo on the object, create a tile for the object, drag it and drop the tile onto the project. If you've done it right, a little 'Got it!' message will briefly appear. The tile will then show up inside of the project. Next, open that project, select the tile, open the halo and then select 'hand me the object' from the menu. Finally, delete the tiles if you want.

(if you don't see 'Got it!' you probably just created a new project so first enter the new project then come back and try the drop again - dmoc)



Question

R. Medow
How to get webbrowser registered to open URL links on a new 3.7b system?
I don't know how 3.6 has been able to do this. But I can see a message saying there is no webbrowser registered.
Thanks.

Answer

I have a 3.6, and from what I see, TextUrl>>actOnClickFor: sends #jumpToUrl to the approriate thingy. Maybe #isWebBrowser is screwed up at your place?
You need to install a web browser such as Scamper via the "Package Loader".
Can someone tell me if there is a class to create bar graphs?
Thanx,
Matthias

Question

How do I configure squeak to use the network? I can't get scamper, SqueakMap, World>help...>update code, or TelnetMachine to connect to anything; even localhost.

Question

How do I stream audio in, then turn it around and stream it out in real time. I can get SoundInputStream to read input and I can get QueueSound to output if I 'add: SampledSound'. However SoundInputStream gives me a SoundBuffer which won't 'add'. How do I make a SoundBuffer into a SampledSound or is there some other way to do this?
Thanks
Bob
How do I add an image button to the "object catalog"?
Can squeak be integrated into an external project and an external environment? a) Can it be used to create stand-alone applications that use an external GUI, e.g. GTK etc., and don't require the squeak desktop to appear? b) Can the squeak application be integrated into a project containing source code from other languages, so that the squeak application and the source files can be under version control, together?


How do I bind graphic controls, eg the slider, to my Mac keyboard? (Perhaps related to this, how do I deal with files that have a '.sar' suffix? I've found one called 'keyBinder.14-08-2004.sar', but as a naive beginner in Squeak, I would need very detailed instructions in how to use it.)
How can I read a string from the keyboard? I tried to use the InputSensor and it's wait-functions, but this causes Squeak to hang up.
whSKQ10h8gxQBg ryMp4ESEQU X0hFDml29am


Have a question? Add it here!



Last update [02-Oct-04]