0

Read from text file

How do I read data from a text file and store it in a number/string register?

Thanks

6 comments

Date Votes
0
Avatar
Michael Johnston

1.046  MATH         @file = "F:\\METBASE\\Shared\\Data\\5720A_Nominal.dat"
1.047  MATH         lastDate = READ(@file,2)

If you pull up the READ function in the MATH FSC portion of the help file it explains pretty well, but best practice is to set the file address to a variable since it will likely be long. Then just use MATH again to set the result of the READ function to whichever register you want to use. The number after the comma is the row number you are pulling from the text file.

For the file address, use \\ in place of \ to get the actual backslash.

0
Avatar
Kierran Purden

Thank you very much, this will come in very handy!

0
Avatar
Kierran Purden

I should have stated earlier that I'm using Met/Cal version 7.2. I have tried your method and it actually works perfectly, but the reason I could not figure this out myself is because it is not mentioned in the reference guide for this version.

According to my reference guide, the MATH FSC does not have a function called READ.

Just thought I would point this out, but like I said it's working so it's not an issue

0
Avatar
Michael Johnston

Oh, yeah, the help file in version 8 is a huge improvement for sure.

0
Avatar
Kierran Purden

Yeah, the help file for 7 is lacking in a few areas. Just need to convince the company to buy version 8 and actually spend money on gold support 

0
Avatar
Michael Johnston

If you email softwaresupport@flukecal.com, they might be able to send you the updated help file. You'll have to keep in mind that some FSC's aren't supported, obviously, but it could still help out in the meantime.

Please sign in to leave a comment.