05-18-2010 01:34 PM
How can I read numeric data from a text file?
Actually, I want to use a while loop and each time just read one array (one line) from the file.
Then convert array to cluster. (I know this step, I used the function "array to cluster", right? )
Then assign this cluster to be the robot coordinates. (I connected the output of "array to cluster" to the "denso move by coordinates")
Anyone has any suggestions for me? Thanks!
Solved! Go to Solution.
05-18-2010 03:42 PM
Hello,
You have quite a few options to do this, and the best solution really depends upon what you are wanting to accomplish. Here are a couple basic options, though.
First, is it important that you read from the text file each iteration? Could you simply read out the entire file's position data then cycle through that data later? If so, you could just read the file once at the beginning and use a FOR loop to cycle through the points. Here is a screenshot of an example:
This example reads a text file with the following data:
0,0,0,0,0,0,5
140,0,40,90,0,180,5
0,0,0,0,0,90,5
It will read out the data into a 2D array which can be fed directly into a FOR loop to cycle through each line of position data. The use of indexed tunnels allows the FOR loop to only iterate the number of dimensions of the array (number of rows in this case). Note that when using the Array to Cluster function, you will need to specify the number of elements as 7. It does not dynamically adjust. If you must read from the text file each iteration, here is another simple example using a While Loop:
Again, simple examples so you would want to make sure and check the robot status and do proper error handling for each method. Is this close to what you were looking for? I would also look into the File I/O examples that ship with LabVIEW for other options.
05-19-2010 07:50 AM
Thank you for your fast response! In first case, does the for loop automatically read one row each iteration? anything else I need to set?
05-19-2010 01:32 PM
10-10-2017 10:43 AM
Can I have your IV?