
Now that you have make some things using Squeak we can begin to talk about Smaltalk, the language used at the Squeak world.
Each object has its group of functions (we like to cal then: methods). A method can have parameters like in:
Out1 setCharacters: 'abc'.or can have not, like in:
Out1 hide.
It's usual to call the first type of method: "keyword message" and the second type "unary message" and say that : "the object receives a message". I think that this terms are a little confuse... Better to say: a script executes many methods of many objects.
Squeak objects don't have properties like in some other languages. We only have methods. When we see in the Viewer:
Text color: somecolor.color is not a property. The line of code means someting like:
Text setMyColorTo:somecolor.
But it's usual to call this methods: properties...
Old Smalltalk programers, having the confuse concept of "messages", like to call mathematic operations: binary messages...
The signals for this operations are the usual in programming:
+
-
*
/
At this lesson, our exercice will be to create a simple useless calculator that only does sums.
If you need to use many objects of the world inside a script (created always glued to an object) you need, first, to put, visually, a line of the Viewer of each one of this objects inside the script. You can erase this lines after, in the "editor window" of the script.
So: we will create 3 Text-with-border and call then: In1, In2 and Out1. The script will be glued to Out1. We need to put, visually, lines of the viewers of In1 and In2 in the script.
We erase this lines and write the final script:
self setNumericValue: In1 getNumericValue + In2 getNumericValue.like we can see:
DON'T FORGET THE "accept"!
Creating the button to fire the script, saving the project etc. etc. you can play with it here, typing new numbers (you can use decimals) and clicking the button. You can initialize the project without any numbers in the fields (erase then using the tab key of the keyboard), create lines of instruction etc.:
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
