Quote Originally Posted by Christos_K
Also a question about Arrays.

I want to create an array with byte values in it and read and write to it. Will this be correct:

Array1 var byte[4]
.
....
.
for i=0 to 3
array[i]=i
i=i+1
next i

will this give the following result??
array1[0]=0
array1[1]=1
array1[2]=2
array1[3]=3

Thanx!
The value of i is automatically incremented by the for next loop, so just remove the i=i+1.

This will give you the results you're looking for.

Array1 var byte[4] ' declare a 4-byte array

for i=0 to 3 ' index array elements 0 to 3 (4 total)
array[i]=i
next i

Array elements start at 0, and end at the declared size-1. I.E. Array VAR BYTE[4] gives you
4 byte sized elements in the Array that are indexed 0 to 3.

If you do this;

Array1 var byte[3]

for i=0 to 3
array[i]=i
next i

You'll end up placing the 3 in a RAM location outside your 3-byte array.