alice-teacher (object)'s variable named (variableName) of type (valueClass) function help

Don Slater dslater at andrew.cmu.edu
Mon Dec 5 12:14:26 EST 2011


If I understand your question, and I am not sure that I do, a function is an expression that returns the result of some sort of calculation, and therefore has to be on the right hand side of an assignment statement, or a parameter argument to another method. Alice does not allow functions to stand by themselves in the run (or any other method), which is different from a procedure.

If I am not understanding your question, I would be happy to look at an example world.

All the best,
Don Slater

On Dec 5, 2011, at 10:41 AM, Melia, James E. wrote:

> I cannot drag a function to the run programming screen in Alice 3.0- the entire screen turns blue. What am I doing wrong?????
> I would like IF bunny within 2 of duck, THEN bunny goes up 2.... a simple If/Else statement.
> 
> Jim Melia
> 
> -----Original Message-----
> From: alice-teachers-bounces+jmelia=bcps.org at lists.andrew.cmu.edu [mailto:alice-teachers-bounces+jmelia=bcps.org at lists.andrew.cmu.edu] On Behalf Of Don Slater
> Sent: Sunday, December 04, 2011 9:28 PM
> To: Alice educators
> Subject: Re: alice-teacher (object)'s variable named (variableName) of type (valueClass) function help
> 
> This is a bug in the current version of Alice 2.2, which should be fixed in the next release, which will happen in the next couple of days...
> 
> Thank you for your patience,
> 
> Don Slater
> 
> On Dec 4, 2011, at 11:54 AM, Findley, Scott wrote:
> 
>> Question from a student regarding: (object)'s variable named (variableName) of type (valueClass) function help:
>> 
>> I'm trying to have Alice check the value of a variable in a list of objects and if that test returns false, I want to set that variable to a random number. However, alice's built in function for this, (object) 's variable named (variableName) of type (valueClass), only seems to be able to drop if the stars align (ie, I have no idea why it sometimes accepts it but mostly won't let me drop it in my code). Also I have only been successful in getting this to work when I'm checking a value in an if statement, however I also want to set the variable to a number. Here is kind of what I want my code to look like:
>> 
>> for all world.spawnPoints one item_from_spawnPoints at a time
>> if ((item_from_spawnPoints's variable named timeBuffer of type Number) <=0) //this I managed to do but it was very difficult to to get the function in there and I'm not sure how I did it.
>>  //do stuff
>>  item_from_spawnPoints's variable named timeBuffer of type Number set value to world.random number //I have no idea how to do this line...
>> else
>>  //do other stuff
>> 
>> I realize I could get around this by using multiple class level methods and having them change their own local variable, but that kind of defeats the whole purpose of a list (plus, I don't want to make 10+ methods when I could just use one).
>> I'd appreciate any solutions you guys have.
>> 
>> 
>> Mr. Scott Findley 
>> sfindley at sd43.bc.ca
>> Gleneagle Secondary School http://gleneagle.org
>> Mr. Findley's Homeroom Site    Twitter @ rsfindley    Mr. Findley's Blog @ Posterous    Writing 12 Posterous Site    
>> 1195 Lansdowne Drive, Coquitlam, BC V3B 7Y8  604.464.5793 / 604.464.5796 (F)
>> While email is repeatedly checked, I typically reserve an hour daily for correspondence. Should you need a more immediate reply, please flag your message as urgent. Any emails received without a clear indication of the sender will receive no response.
>> 
>> This e-mail (including attachments, if any) may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
>> 
>> Unless absolutely necessary, please do not print this email for environmental reasons.
>> 
>> 
>> 
>> _______________________________________________
>> alice-teachers mailing list
>> alice-teachers at lists.andrew.cmu.edu
>> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
> 
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
> 
> 
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
> 



More information about the alice-teachers mailing list