Alice Community  

Go Back   Alice Community > Alice 2 > Suggestion Box

Reply
 
Thread Tools Display Modes
definning paramerters and variables suggestion
Old
roofy
Guest
 
Status:
Posts: n/a
Default definning paramerters and variables suggestion - 10-14-2006, 12:56 PM

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
else
nothing

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.
   
Reply With Quote
Integer data type missing in Alice.
Old
DrJim
Guest
 
Status:
Posts: n/a
Lightbulb Integer data type missing in Alice. - 10-14-2006, 02:05 PM

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. 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.

Jim
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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