The mechanism of Read File is not explained. What does it read? A line? A value from a line? What?
There is no apparent way to check EOF when reading a file.
Here;s what I want to do: I want a file called "calibration.txt" which contains, ideally, lines of the following form
I am making a moisture sensor that senses up to 7 flowerpots. I set up the default value at the suggested 1500, but this may not be suitable for all flowers. I want the end user to be able to set the calibration for each flowerpot by putting a file called calibration.txt on the CPX. Then I do (in MakeCode)
Code: Select all
if fileExists("calibration.txt")
...magically read data
and I have no idea how to write the loop that magically reads data. The documentation is remarkably silent on how this mechanism would work. I am starting to experiment, but it would be better if I had a real piece of documentation that showed how to read a file.
I want to also, if there is an error, do something like blink the lights all red on and off for several seconds. So assume I want to do input validation. If the data is
or similar kinds of whatever I declare as nonsense, I want to indicate an error. Since there can be at most 7 lines in the file, I can blink all the lights red except one, which I will blink blue, and it will indicate what line the error is on.
But without knowing what read file does or how to use it, it is impossible to write this code.