LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random access files

Hi ,

I would like to generate random access files from labview for reading with vba or Fortran.

I would like to know adressing the length of record and the position of pointer with labview.

Kind regards

0 Kudos
Message 1 of 7
(4,413 Views)

You are referring to writing binary files, though technically all files are binary since they're just a sequence of bytes. LabVIEW has the Write Binary File function to do this. There is also the Set File Position function. All of these functions are available in the File I/O palette. There are also examples that ship with LabVIEW. Have you taken a look at these? What kind of data are you trying to write?

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Message 2 of 7
(4,390 Views)

Thank you for your answer but I the know the vi "write to binary file"  it is of few help for my concern. What I mean is to write formatted direct access binary file with defined record length or differently said  what I need is a way to write data from labview which are uneditable with an ascii editor or XL and could only be retrieved with a VBA for xl or Fortran code.

With kind regards

0 Kudos
Message 3 of 7
(4,362 Views)
That's precisely what the Write Binary File does. It allows you to write to a binary file in whatever way you want. Why do you think it won't work? What kind of data are you trying to write? What are these "records" that thou speakest of?
Message 4 of 7
(4,345 Views)

Mostly the records  that I speak of are strings cast  by "array to spreadsheet string" vi. It is not very obvious in the help section of Labview to figure out how the string are written in binary.

Is it like they are recorded in memory ?. An handle of 4 bytes for the length of the string followed by an array of octets (one octet for each character). Is it right ?

To be frank the way I'd like to use would befirstly record the strings columns header as strings, secondly record numeric values as they are collected coded as double precision floating number using "write to binary file VI". But I am not sure that it is allowed to mix data types within a binary file.

 

 

0 Kudos
Message 5 of 7
(4,321 Views)

The concept of a "record" has faded away.

 

The suggestion to write the file as binary is the right approach.

 

For random access to your file the strings have to be of fixed length so we can know the offsets within the file. There are operators on the strings pallette that will let you create a string of fixed length and then replace that portion that represents your data. I think you will need to use null terminated strings so the reading code can tell where the string ends (no sting length available).

 

Then just append your floats after the header portion of the file.

 

Just trying to help,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 7
(4,318 Views)
Thanks a lot Ben, I am going to work that way.
0 Kudos
Message 7 of 7
(4,302 Views)