LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set file position issue

Solved!
Go to solution

Hello everyone,

The issue I am getting is the folowing:

I would like to add to an already existing .txt file other data. To do so, I am using "Set File position"  function to determine the current file mark. This function accepts as an input ONLY a refnum!!!

but in my case I just have a path file ( not a refnum !!) . How can I generate from the path I have, a refnum to use it as an input for the "Set File position"  function ?

 

N.B.: Please read the comments in the VI 🙂

 

Thanks in advance for any help you can provide,

regards,

F

 

0 Kudos
Message 1 of 6
(4,565 Views)
Solution
Accepted by topic author feriel0209

If your file exists, you have to open it....

0 Kudos
Message 2 of 6
(4,557 Views)

Use the Build Path function instead of all the string concatenation and the string to path function.

Message 3 of 6
(4,549 Views)
Solution
Accepted by topic author feriel0209

Well, it makes no sense to set the file position on a file that is not even open.  So open the file first.

 

And since you are adding data to the end of the text file, set the file position relative to End instead of Current (and Current will be 0 when you first open the file).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(4,543 Views)

The OS does not maintain a file pointer for a file that automagically gets reused when you open a file. You have to open the file, set the file pointer on that open file reference, do your write and/or read operation and then close the file. Once you close the file the file pointer that was maintained for that file in that file reference is lost and when you open the file again it opens with a new file pointer initialized to the beginning of the file.

 

And changing Windows and LabVIEW to make it work as you would like is not an option, so you have to change what you do.

Rolf Kalbermatter
My Blog
Message 5 of 6
(4,513 Views)

I tried yesterday to open it before writing on it, but I got the1059 error !

But now it is working!  weird!

Thanks

0 Kudos
Message 6 of 6
(4,501 Views)