Here are some things that will give you dramatic speed improvements.
- Do not read the entire file all at once. Reading 1.4MBytes
at once is a slow operation. It is far faster to read the file in
65,000 character chunks. You can process it in chunks as well,
which brings us to the next point.
- The function you use to find a line has to scan the entire input
string every time you use it to find the line you need. Since you
are processing the lines sequentially, you can easily go through your
data sequentially using something like the match pattern VI to split
the string into a line and whatever is left. I would strongly
advise you to look at how the Read LabVIEW Measurement File
express VI handles string input. You can probably copy large
chunks of this code, since it is doing almost exactly what you are
doing (reading in a file and parsing it line by line).
- Your command detection scheme is very inefficient. Get rid
of the inner FOR loop. Instead, take the two character command
you are extracting from the string and use it as the input to a case
structure. The cases of the case structure then become your
commands (make sure to include a default for unknown or corrupt
commands). This will reduce your number of compares from 21 per
line to 1 per line.
Let us know if you need more help. There are more ways to attack
this problem than the ones I listed, but they should get you there.