Alright, I know that may sound confusing - I'm an new one on the idea of programming. I have a CNC project that will take values from a text file, assign them, and transmit them via a serial connection to an Arduino which will receive and drive the motors, so on, so forth.
for( std::string line; getline( input, line ); )
{
int x, y;
input >> x >> y;
}
But, I want to be able to have the program process any length of a text file - any number of coordinates. In the interface I am designing a entry panel that would allow the user to specify the number of the commands. But, how do I introduce code that would take that number of commands and introduce that number of variables? I understand I could brute-force this by creating 1000
variables of each X, Y, Z
, and other command types, and have up to 1000
possible line processing, but it would be much more efficient to have code that realizes this and adjusts for me.
Say, for example, I have that text entry box output a value designated NumberOfCommands
. How would I tell the program to create a number of X-axis, Y-axis, and Z-axis
(as well as other serial) commands where that number is equal to NumberOfCommands
?