LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fixed length reccords files

is it possible to write/read fixed length string reccords files, and access them by reccord numbers. Like 'get'/'put' in BASIC language or 'seek' in C ?
0 Kudos
Message 1 of 6
(3,484 Views)
Yes, the file IO functions in LV have the ability to write data into the middle of files. In other words, starting X number of bytes into the file, write N characters.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 6
(3,484 Views)
Look at the help for the function in the File I/O palette. Write File and Read File both have a pos (position) mode and pos offset which let you specify the position in the file where the write or read operation should start. Read File has a Count input where you can specify the record length. The Seek function on the File I/O >> Advanced palette lets you position the file pointer.
If you don't know how to view help for functions on a palette:
Create a new VI.
Press H to bring up context help.
Goto the diagram of the new VI.
Right-click any blank space on the diagram.
Point to the palette of interest (in this case, File I/O with a diskette icon).
Point to any function within the palette to see the context help. Some functions have more help (the Co
ntext Help window will show a link "Click here for more help."
Message 3 of 6
(3,484 Views)
I ve got no problem to read a fixed length string file with the 'read file' VI.
My problem is to make/update them.
When i try to use the 'Write file' vi, it needs a specific file format and refuse to create/update my file.(no header, fixed length string reccords), no separator)
Would it be hard to make such thing by using a C dll ? or may be it already exists ?
Thanks for caring.
0 Kudos
Message 4 of 6
(3,484 Views)
Write file needs a specific file format only if you opened the file as a datalog file specifying the file format. How did you open the file? If you use Open/Create/Replace File.vi and specify function = 2 (Create or Replace), you can write any kind of data to the file. See the attached example. The numeric will be written in the IEEE floating point format, the string will be in ASCII.
0 Kudos
Message 5 of 6
(3,484 Views)
Thanks, You were right, I was using bad function to open my file.
It 's strange that when i try to add a reccord in 'mode pos 0' (from the begining of file + offset), it says EOF reached, but in 'mode pos 1' (from end of the file + offset) it works well.
Anyway i m happy, it now works, thanks again.
0 Kudos
Message 6 of 6
(3,484 Views)