LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

MathScript equivalent of ftell()?

First time poster and pretty big newbie to LabVIEW.

 

I have a few MatLab scripts that I'd like to make a part of a LabVIEW VI, but rewriting them is turning out to be a pain. One issue is that MathScript does not appear to have an ftell() function.

 

Is there any other way to get the file-position? My script has several while loops that terminate when the file-position reaches a certain point (probably bad practice, but these are old files that are not going to change format). And it also writes the position to a text file under certain conditions, so that the script can end and start back at the correct position later.

 

It would be great to be able to do this with MathScript.

 

Thanks,

Rob

0 Kudos
Message 1 of 5
(6,777 Views)

Hello Rob,

 

I was hoping to clarify which script interface youa re working with: 1.) The Mathscript Node, or 2.) the MatLab Script Node? 

 

 

Would it be possible to handle the File I/O in LabVIEW, and retrieve file position through LabVIEW primitives? What types of files are these, binary ,text, csv? 

 

I appreciate the additional information, looking forward to hearing your responses.

 

Cheers!

Patrick Corcoran
Application Engineering Specialist | Control
National Instruments

0 Kudos
Message 2 of 5
(6,752 Views)

I apologize for not being more clear. I am using the MathScript nodes, as I am working on Macs and I believe Matlab Script Nodes are only supported for Windows.

 

It is probably possible to do with a mix of LabVIEW primitives and MathScript, but I still don't know my way around LabVIEW very well.

 

The first thing I do is read a binary file in, which has a bunch of ASCII stuff at the beginning. Once I reach a certain point in the file (I was using ftell to indicate where the ASCII ends, since it's the same for every file we're dealing with), I stop that loop and begin reading in floating-point numbers.

 

However, these binary files are created during week-long cooldowns of our cryogenic chamber and we would like to analyze them while they are still being written. This was the main reason I used ftell. If the file was not complete, I would write a text file with the byte position in it so that the next time we would run the script, it would check and see if the csv already existed, then start the loop where it left off.

 

After I get all this info from the binary, I write a CSV file that we save. Then analyzing a csv file is easy, so no worries there.

 

I had done all of this in MatLab without too much effort actually, but it appears that I am no where near able to just drop those files into MathScript Nodes, so if you could point me to any info on how to do something like this in LabVIEW, that would be excellent.

 

Also, the files are little-endian, which I could specify in MatLab (since Macs read/write big-endian by default) when using fread. Is there a way to tell LabVIEW which "endian" the files are?

0 Kudos
Message 3 of 5
(6,748 Views)

I think architecture can be implemented with VIs from the LabVIEW File I/O Palette. (Right-Click the Block Diagram to bring up the Functions Palette >> Select Programming >> File I/O >> Advanced File Functions)

 

On the Advanced File Functions Palette, you will find both the Get File Position, and the Set File Position VI. 

 

SetFile Pos.jpg

 

 Would it be possible to implement these VIs for the File I/O operations, and continue to do you processing with the Script Node?

 

Please post any further questions, or a VI with your implementation of this File Structure.

 

Thanks, 

Patrick Corcoran
Application Engineering Specialist | Control
National Instruments

0 Kudos
Message 4 of 5
(6,712 Views)
Yes, thank you for the help. Those will work fine. Worst case scenario was that I was going to count the bytes manually in the script by some byteCount = byteCount + 1; method.
0 Kudos
Message 5 of 5
(6,681 Views)