Arrays on vex

Is it possible? i’ve setup a data array(int array1[40] or so), and it compiles… but i can’t seem to get it to work. When I try and print to it:
for(x==0,x<40, x++){
PrintToScreen("%d\n", array1[X]);
}

Or somethhing like that… i don’t get any printing, at all.

Anyone have experience with this?

Thakns

Well, for one thing, x==0 should be x=0.
x==0 is a test to see if whateve is in x is zero.
x=0 sets x to 0.
If x had something in it greater than 40 when you started, the loop won’t run.

I believe the problem is in your initialization of x when you begin the For loop. You are using ‘==’ which compares the two values instead of ‘=’ which assigns 0 to the variable x.

Grok

Doh, that explains a few other things…

Thanks guys :slight_smile:

I have done the same thing more times than I can count.

There are limits to the size of arrays, but your example would not exceed them. The PIC has a memory banking scheme and I think the default max segment is something like 256 bytes. Look in the 18f8520user.lkr file for the actual values. It’s possible to make larger chunks, but then you have to figure out how to edit the .lkr file to combine banks without blowing things up :stuck_out_tongue:

Steve