Couple of problems I'm seeing with the code (besides the error messages);
Your code will get stuck here. The "While" loop checks to see if a condition is true, and if it is it then runs the code within the brackets and rechecks to see if the condition is still true when it hits the end bracket. You've made what's called an infinite loop; "True" will always be "True", so the code will always run. The problem is that the only code within the brackets is the commands to move the motors forward so that's all the robot will do; move forward.
This is a bit more complex. Generally the threshold value is a value that you pre-set that tells the robot if a sensor value is between two conditions. In this case, anything above the threshold would be considered "light" and anything below the threshold would be considered "dark". I believe for this particular set of code is trying to find a function called "lineDetected", send up the individual sensor values, and get a boolean (1 or 0) value back depending if the sensor is above or below the threshold value. Although more efficient, it's a bit more complex going this route. There are two alternative routes that come to mind right this moment (there are probably many, many other options);
One option is to use multiple multi-condition if/else statements:
This will basically check for "111" and then you can code accordingly. Changing any of the conditions to a '>' value (meaning, the sensor is reading light, aka not a line) will change the comparison to a 0) and then code the robot to perform actions accordingly. The problem with this is that you will have a good bit of code to go through, and the more code you have the more places you have to make an error.
Another option (and this is a bit more complex) is to use if statements to read the values from the sensors, append them to a string, and then read the string directly and compare it in a switch statement. This approach is a bit more complex but cuts down the amount of code by a good bit.
The absolute best way to do this, though, is the way that is most comfortable for you
When you make the code your own, you truly master it and can start tapping into the deeper powers of the programming languages.
Watch the "Forward Until Dark" videos under the "Sensing" tab to learn a bit more about threshold values:http://www.education.rec.ri.cmu.edu/pre ... x_preview/
If you decide to go the string/switch route, you can learn about the 'strcat' command at our wiki:http://www.robotc.net/wiki/General/Strings
And you can learn about If/Else and Switch statements a bit more in "Line Tracking" under "Sensing":http://www.education.rec.ri.cmu.edu/pre ... x_preview/
The good news is that this knowledge will help you in not only other ROBOTC programs but also in most other programming languages, as the general principles (string manipulation, comparative operators, conditional statements) are shared across languages.
The absolute best thing I can recommend is to start from scratch and make your own code. That way you go through the trials-and-tribulations, you learn more from it, and you can debug it better if it goes wrong. Plus, you avoid using code that is overly complex for what you are trying to do or contains extraneous code.
Good luck, and keep us updated!
Check out our Blog
! And our Facebook page
Need help? Take a look at our Wiki
and our Forums.I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody