Alice Community

Alice Community (
-   Suggestion Box (
-   -   definning paramerters and variables suggestion (

roofy 10-14-2006 12:56 PM

definning paramerters and variables suggestion
I know that Alice is now in the hands of EA sports, but could who ever knows how to contact EA sports, mention to them that parameters and variables include the difference between float, integer values? I already had two incidents so far when Alice returned a parameter false becuase the parameter was an integer and the check condition was a float.

for example.
I got an event that says this

When anykey is typed,
do sphere.speak whichKey=code

the method sphere.speak looks like this
parameters whichKeyCode

if whichKeyCode == 38 then
sphere say the upArrow key was pressed

now when I originally did this, the parameter whichKey was 38. However the if statement was checking it like this...

if 38 == 38.0

these are totally two different types of varibles. The "38" is a integer, and the "38.0" is a float. In addition, even if you put the round function in front of the value 38.0 it still reads as 38.0 which causes the if statement to always be false, and this is annoying.

DrJim 10-14-2006 02:05 PM

Integer data type missing in Alice.
I agree that this is one of the more annoying design choices made in Alice 2.0 (although from an educational standpoint, I agree with it). Think you can solve your immediate problem by a de facto integer to floating point conversion by adding a small, non-integer amount to both your integer and your test variable, i.e., add 0.01 to 38 and then test for 38.01.

I've tested this about a half dozen times and it seems to work, but please let me know if it fails for you. :confused: I think (or at least hope) the long term solution will be in Alice 2.1 where you will have access to true Java functionality.


All times are GMT -5. The time now is 05:00 AM.

Copyright ©2018, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.