LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving the path of a text file for future runs.

Hi everyone. This is my first post on the forum. Please excuse me if my question seems incomplete.

 

Coming to my question, I am using Labview 2012. What I want to do is to read a data from a text file and save the path of this text file for every successive run of the vi. I am using the read from text file vi. In the first occurence, I give the user a prompt to find the file he wants to read,but from the next occurence I want the user to be able to continue without being asked for the file path unless he wishes to change the file.

0 Kudos
Message 1 of 7
(2,733 Views)

Hi Apoorv42,

 

as usual: you need to save the file path in a file and load this file at the start of your program.

 

You can save data in arbitrary text files or use Configuration (aka INI) files for that purpose.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,715 Views)

Hi GerdW, 

 

Thanks for your reply. But my problem is that the first time I have to ask the user to choose a file from the dialog. How do I wire separate inputs to the read from text file vi? I need a blank input(i.e. open a dialog box)  on the first occurence and to remember this path and wire to the same input on further occasions.

0 Kudos
Message 3 of 7
(2,709 Views)

Hi Apoorv42,

 

you need some progam logic involved:

load(filepath from INI file)
IF filepath == "empty path" THEN
  filepath = FileDialog()
ENDIF
LoadFile(filepath)

 Do you think you can create a simple case structure like described by this pseudocode?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(2,698 Views)

Hi GerdW,

 

I was also thinking on similar lines but the problem is how to compare the input of read from file vi with an empty path. I am attaching a VI for your reference in which I am trying to implement a case structure as per the code. The front panel is empty. Please find the case structure in the block diagram.

0 Kudos
Message 5 of 7
(2,689 Views)

Hi Apoorv42,

 

as I can't open your VI (due to it's LabVIEW version) I recommend several ways of checking a path:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(2,683 Views)

That VI is just storing the reference to a file.  As soon as it goes out of memory, that reference is gone.  Besides, you really need to be closing your references.

 

There are several functions available to see if the path given is empty (Empty Path? is found in the comparison palette) or if the file even exists (look in the File->Advanced palette).


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
0 Kudos
Message 7 of 7
(2,657 Views)