Newbie Simple NXC code problem with array
Posted: 01 Feb 2012, 01:10
Hi,
Just started using NXC.
Want to make a connect 4 Robot Game (with NXT display).
At the moment I can't even get an int value out of the array and test it.
Please explain, I get "File error!".
the line: "ArrayIndex(myVal,col1,i);" - is the issue as it seems to cause the "if" to fail.
Just started using NXC.
Want to make a connect 4 Robot Game (with NXT display).
At the moment I can't even get an int value out of the array and test it.
Please explain, I get "File error!".
the line: "ArrayIndex(myVal,col1,i);" - is the issue as it seems to cause the "if" to fail.
Code: Select all
//This program should output the position in array col1
// where the 1st "0" is encountered. should display "2"
//
int myVal = 0;
int currentCol = 1;
int colEmptyLocation = 0;
int col1[6], col2[6], col3[6],col4[6], col5[6], col6[6], col7[6], col8[6];
//
//
task main()
{
//test values
col1[0]=2;
col1[1]=2;
col2[0]=1;
col2[1]=1;
col2[2]=2;
col3[0]=2;
//
for(int i=0; i <= ArrayLen(col1); i++) {
//either line below does not work! causes "File error!"
//myVal= col1[i];
ArrayIndex(myVal,col1,i);
//
if (myVal==0){
colEmptyLocation = i;
NumOut(10,LCD_LINE2,colEmptyLocation);
i = 100;
}
}
Wait(10000);
}