I think ChucK can get pretty confused about this line:

x[msg.which] => int x;

...in which x is treated both as an array and as a newly declared integer variable. I would rename the array to avoid confusion.

/Stefan

On Wed, Apr 22, 2009 at 2:04 PM, Hans Aberg <haberg@math.su.se> wrote:
I encountered what looks like a bug. In the sample code below, the array indexing in the line with the assignment of x0 causes the following error:
 [bug597534.ck]:line(22): array subscripts (1) exceeds defined dimension (0)
It does not happen when the same kind of construct is used in the top loop, also as in the example code.

 Hans Aberg


----
Hid kb;
HidMsg msg;

if(!kb.openKeyboard(0)) me.exit();
<<< "Keyboard '", kb.name(), "' ready." >>>;

// Key x-axis coordinate
int x[256];

while(true)
{
 kb => now;

 x[msg.which] => int y;
 x[msg.which] => int y0;

 while(kb.recv(msg))
 {
   x[msg.which] => int x;
   x[msg.which] => int x0;
 }
}
----
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



--
Release me, insect, or I will destroy the Cosmos!