Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Problem with arrays
Old
Olaf
Guest
 
Status:
Posts: n/a
Default Problem with arrays - 07-20-2009, 06:56 PM

Hi,
I have a problem using arrays:
I have an array "a" with two elements. Now, I want to put the second element to the first place.
So, I wrote: "Set item 0 to item 1 from a in a"
When I start the program, get an error message: "Error during simulation".
Do you know why?
The same happens, if I try to change both elements ...

I added the simple program, so that you can have a look ...

Thanks,
Olaf.
Attached Files
File Type: a2w ArrayProblem.a2w (362.7 KB, 4 views)
   
Reply With Quote
I am lost here.
Old
Veryuhbull
Guest
 
Status:
Posts: n/a
Unhappy I am lost here. - 07-21-2009, 11:59 AM

Do you want the objet trade places? Because, there are easier ways to do that.

First drop dummies on the objects then add this to the method.

doinOrder:
chicken set point of view to dummy1
bunny set point of view to dummy2

Or if you just want them to change order in the array (which has no visible effect)

setitem 0 to chicken in a duration 0
setitem 1 to bunny in a duration 0
   
Reply With Quote
Old
Olaf
Guest
 
Status:
Posts: n/a
Default 07-21-2009, 01:19 PM

No, thats not what I wanted.
Thats only an example. In the array could also be numbers.
I just want to know, if it is possible to execute an statement like
a[i] := a[j]
in Alice, if a is an array and i and j are some numbers.

That is for example necessary if you want to sort an array of numbers ...

Any idea?

Thanks for your help,
Olaf.
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.