I am looking for help with a script or to help guide me to a script that will allow me to read contents from a saved file and compare to a string value.
I already have a script that will get the value of a servo, and store it to a file. I would like to read that same file and compare the values.
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!
So $contents1 through $contents4 variables store the data of the first 4 lines of data that was in the file respectively...
Maybe I need to read from the file and then make an array then compare all the array entries to the servo value?
I assume you want to write servo positions to be saved and resumed at a later date?
@WayneA... what DJ said...
Lets say you had 3 variables you wanted to store in a text file, like servo values or whatever. You'd have a "ReadFileScript" to read the values from the file to give you your base line data.
These would be active current values for the variables.
$value1 = 1
$value2 = 2
$value3 = 3
Then I would have a "WriteFileScript" that would delete the file and re-write the data in the file when needed.
I'd have another script to watch for changes to the values, if they change then kick off the "WriteFileScript".
I don't think you'd want to lump them together and I don't think you'd need to read and write together, you should only need to read the file when the program starts. After that you just want to write data when values change.