I just discovered Bots Inc. and am trying to render some of the lessons within Etoys.
In Bots Incs. when you click on a Bot a balloon pop's up and when you enter text and hit <return> the text you entered is executed. How can I execute a command (do it) on <return>?
Also, I have a script that on mouse over prints:
Im a Bot. My position is: 769.5@452.5 and my direction is:34.3357941965284
How do I print integers or specify that I only want 2 digits to the right of the decimal point? (Below is my script). script1 | tmpStr | tmpStr := 'Im a Bot.\My position is: ' withCRs , self getLocation printString , '\and my direction is:' withCRs , self getHeading printString. self sayText: tmpStr
Thanks, Stephen
On Friday 25 Feb 2011 12:07:42 pm Steve Thomas wrote:
How do I print integers or specify that I only want 2 digits to the right of the decimal point? (Below is my script). script1
| tmpStr |
tmpStr := 'Im a Bot.\My position is: ' withCRs , self getLocation printString , '\and my direction is:' withCRs , self getHeading printString. self sayText: tmpStr
see printShowingDecimalPlaces: in Integer>>printing category. Also search for 'places' in message window for other options.
HTH .. Subbu
Subbu,
Thanks it did help, I got it to work, but I don't understand the following and not sure if it is a bug in Squeak or in my head. I ran the three commands below in a workspace and don't understand why the first one failed
Transcript show: 2.54343 printShowingDecimalPlaces: 2 - Failed Message Not Understood t2 := 2.54343 printShowingDecimalPlaces: 2 - OK Transcript show: t2 - OK showed 2.54 in Transcript
Stephen
On Sun, Feb 27, 2011 at 9:11 PM, K. K. Subramaniam kksubbu.ml@gmail.comwrote:
On Friday 25 Feb 2011 12:07:42 pm Steve Thomas wrote:
How do I print integers or specify that I only want 2 digits to the right of the decimal point? (Below is my script). script1
| tmpStr |
tmpStr := 'Im a Bot.\My position is: ' withCRs , self getLocation printString , '\and my direction is:' withCRs , self getHeading printString. self sayText: tmpStr
see printShowingDecimalPlaces: in Integer>>printing category. Also search for 'places' in message window for other options.
HTH .. Subbu
FYI, I have the same problem in Squeak 4.2 and Etoys 4.1
Also I noticed that if I use parentheses I can get it to work: Transcript show: (2.54343 printShowingDecimalPlaces: 2) - OK does not throw exception
Stephen
On Sun, Feb 27, 2011 at 10:31 PM, Steve Thomas sthomas1@gosargon.comwrote:
Subbu,
Thanks it did help, I got it to work, but I don't understand the following and not sure if it is a bug in Squeak or in my head. I ran the three commands below in a workspace and don't understand why the first one failed
Transcript show: 2.54343 printShowingDecimalPlaces: 2 - Failed Message Not Understood t2 := 2.54343 printShowingDecimalPlaces: 2 - OK Transcript show: t2 - OK showed 2.54 in Transcript
Stephen
On Sun, Feb 27, 2011 at 9:11 PM, K. K. Subramaniam kksubbu.ml@gmail.comwrote:
On Friday 25 Feb 2011 12:07:42 pm Steve Thomas wrote:
How do I print integers or specify that I only want 2 digits to the
right
of the decimal point? (Below is my script). script1
| tmpStr |
tmpStr := 'Im a Bot.\My position is: ' withCRs , self getLocation printString , '\and my direction is:' withCRs , self getHeading printString. self sayText: tmpStr
see printShowingDecimalPlaces: in Integer>>printing category. Also search for 'places' in message window for other options.
HTH .. Subbu
That's it exactly. Without the parentheses, the Transcript thinks that you are trying to send it the message #show:printShowingDecimalPlaces: which it does not understand. By adding parentheses, you are first sending the message #printShowingDecimalPlaces: to 2.54343 (a Float object), which understands the message and answers a ByteString object. You are then sending the message #show: to the Transcript, which now understands that it should display the ByteString as you intended.
Dave
On Sun, Feb 27, 2011 at 10:37:43PM -0500, Steve Thomas wrote:
FYI, I have the same problem in Squeak 4.2 and Etoys 4.1
Also I noticed that if I use parentheses I can get it to work: Transcript show: (2.54343 printShowingDecimalPlaces: 2) - OK does not throw exception
Stephen
On Sun, Feb 27, 2011 at 10:31 PM, Steve Thomas sthomas1@gosargon.comwrote:
Subbu,
Thanks it did help, I got it to work, but I don't understand the following and not sure if it is a bug in Squeak or in my head. I ran the three commands below in a workspace and don't understand why the first one failed
Transcript show: 2.54343 printShowingDecimalPlaces: 2 - Failed Message Not Understood t2 := 2.54343 printShowingDecimalPlaces: 2 - OK Transcript show: t2 - OK showed 2.54 in Transcript
Stephen
On Sun, Feb 27, 2011 at 9:11 PM, K. K. Subramaniam kksubbu.ml@gmail.comwrote:
On Friday 25 Feb 2011 12:07:42 pm Steve Thomas wrote:
How do I print integers or specify that I only want 2 digits to the
right
of the decimal point? (Below is my script). script1
| tmpStr |
tmpStr := 'Im a Bot.\My position is: ' withCRs , self getLocation printString , '\and my direction is:' withCRs , self getHeading printString. self sayText: tmpStr
see printShowingDecimalPlaces: in Integer>>printing category. Also search for 'places' in message window for other options.
HTH .. Subbu
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org