Hi,
In the aurora tutorial there is an example of how to declare and assign a single dimensioned array of an intrinsic type (by a comma separated list of the values)
Is it possible to initialize and assign in this way arrays with 2 or 3 dimensions?
Is it possible to do that with arrays of simple structures (such as an array of POINT)?
This is not terribly important, but may save on a lot of typing...
Haim
Try this:
sub main()
{
int myArray[3,3]; // 9 elements
int i;
int j;
myArray = 1,2,3,4,5,6,7,8,9;
openconsole();
for(j = 0; j < 3; j++)
{
for(i = 0; i < 3; i++)
{
print(myArray[i,j]);
}
}
while GetKey()=="";
closeconsole();
}
Thanks,
I could not figure out though if this can be done with a structure such as POINT.
point pt[3];
can I assign like this: pt=......
Haim
The short answer is you can't. However if all of the elements of a structure are the same size, and the struture size is a multiple of 4, there is a way to trick the compiler into doing it.
sub main()
{
POINT pt[10];
*(int)&pt = 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10;
for(int x=0;x < 10;x++)
{
print( pt[x].x,",",pt[x].y );
}
while GetKey()="";
}
This works with a point structure because it is comprized of two integer elements and the structure size is 8.
Paul.