ThePCKid wrote:
Found an error in one of your examples!
Original:Code:
| condition | condition := 10 > 3 + 4. "=> true" condition ifTrue: [ Transcript show: '10 > 7. That's good.'] ifFalse: [ Transcript show: 'I think something's wrong....']. [Sensor anyButtonPressed] whileFalse: [ World displayWorldSafely].Fixed:
Code:
| condition | condition := 10 > (3 + 4). "=> true" condition ifTrue: [ Transcript show: '10 > 7. That''s good.'] ifFalse: [ Transcript show: 'I think something''s wrong....']. [Sensor anyButtonPressed] whileFalse: [ World displayWorldSafely].You forgot to escape the apostrophe. You also forgot something else.
Thanks!
Offline
Is Squeak slow?
Open a workspace and paste this in:
Smalltalk garbageCollect. Smalltalk cleanUp
Now doIt.
Offline
FOR NEWBIES:
These two expressions almost do the same thing:
[Sensor anyButtonPressed] whileTrue: [World displayWorldSafely]
[Sensor anyButtonPressed] whileFalse: [World displayWorldSafely]
They both wait for a mouse button to be pressed. Here's the difference: the first one "resumes" Squeak right when the mouse button is pressed, while the second one "resumes" Squeak after the mouse button is released. Try them both by opening a workspace, pasting one of the codes in, "doingIt", and clicking on the background will show you the difference.
Offline
ThePCKid wrote:
FOR NEWBIES:
These two expressions almost do the same thing:[Sensor anyButtonPressed] whileTrue: [World displayWorldSafely]
[Sensor anyButtonPressed] whileFalse: [World displayWorldSafely]
They both wait for a mouse button to be pressed. Here's the difference: the first one "resumes" Squeak right when the mouse button is pressed, while the second one "resumes" Squeak after the mouse button is released. Try them both by opening a workspace, pasting one of the codes in, "doingIt", and clicking on the background will show you the difference.
but [sensor anyButtonPressed] whileTrue: [] will only work if you already have the mouse button pressed.... (otherwise it just won't execute)
Offline
nXIII wrote:
ThePCKid wrote:
FOR NEWBIES:
These two expressions almost do the same thing:[Sensor anyButtonPressed] whileTrue: [World displayWorldSafely]
[Sensor anyButtonPressed] whileFalse: [World displayWorldSafely]
They both wait for a mouse button to be pressed. Here's the difference: the first one "resumes" Squeak right when the mouse button is pressed, while the second one "resumes" Squeak after the mouse button is released. Try them both by opening a workspace, pasting one of the codes in, "doingIt", and clicking on the background will show you the difference.
but [sensor anyButtonPressed] whileTrue: [] will only work if you already have the mouse button pressed.... (otherwise it just won't execute)
Oh. Now I see. Just tested this and you were right:
10000 factorial. "Wait about one second after I doIt'd this chunk of code so it would have time to see that the mouse button is no longer down"
[Sensor anyButtonPressed] whileTrue: [World displayWorldSafely] "Using 'whileFalse:' instead of 'whileTrue:' would make it wait for the mouse button"
I don't know why I added the comments
Offline
Bump, because this topic is useful.
Offline
Smalltalk has not been used for big applications since the 80's.
I am a bit fuzzy on why Scratch was written in "The Latin of programming languages" but I have heard that it is because scratch is supposed to be simple to learn. How can writing an application in a dead language make it easier to learn?
thanks for the tutorial. There are not many good smalltalk tutorials on the internet! Yours is great!
Offline
midnightleopard wrote:
Smalltalk has not been used for big applications since the 80's.
I am a bit fuzzy on why Scratch was written in "The Latin of programming languages" but I have heard that it is because scratch is supposed to be simple to learn. How can writing an application in a dead language make it easier to learn?![]()
thanks for the tutorial. There are not many good smalltalk tutorials on the internet! Yours is great!
Thanks! I'm glad you liked my tutorial!
Last edited by nXIII (2010-11-09 15:52:24)
Offline
Do you know how to fix my Squeak VM?
See http://scratch.mit.edu/forums/viewtopic.php?pid=968840


Offline