LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.txt file can't read after creation of executable

Hello,

After creating an executable of a VI, I can't read or write to a .txt file.
I save the configuration of a RS-232 port in a text file. When I run the VI inside the Labview everything works fine, but when I create an executable and run it I can't read the file or write to it.

Sugestions?

Best regards
0 Kudos
Message 1 of 13
(3,670 Views)
Are you sure that the path to the text file is correct. If you use "Current VI path" it will go wrong because the path to the VI in development is different to the one in the executable.

Try putting the path on screen in an indicator and see what it's looking for.

Regards,

André
Regards,
André (CLA, CLED)
0 Kudos
Message 2 of 13
(3,658 Views)
I ALWAYS put things into a LIBRARY (.llb) file.

That way, I use CURRENT VI's PATH, and strip TWICE to get the root directory.

That works whether you're in an EXE or in the dev. system.

The first strip gets you to the container (EXE or LLB), the second gets you to the containing folder.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 13
(3,642 Views)
Or, even better, do a strip path in a while loop using a shift register and stop when you get a T of the directory output of the File\Directory Info primitive. A bit more computationally intensive, but worth it usually.

___________________
Try to take over the world!
0 Kudos
Message 5 of 13
(3,624 Views)
Even better than that would be a primitive for "current root location" (or similar) that would give the correct answer in both cases. Maybe Darren can make one for us! 😄
0 Kudos
Message 6 of 13
(3,620 Views)


@altenbach wrote:
Even better than that would be a primitive for "current root location" (or similar) that would give the correct answer in both cases. Maybe Darren can make one for us! 😄

Tell me specifically what you want the function to do (with examples please) and I can get it on the radar...I've heard requests like this before, but I need details.

-D

0 Kudos
Message 7 of 13
(3,550 Views)
Here's what I had in mind.
  • If we are running a VI, it should give the path to the folder where the VI is located.
  • If the VI is in a llb, it should give the path to the folder where the llb is located.
  • If we are running an executable, it should give the path to the folder where the executable is located.
For example, if we have a custom configuration file needed for the application, the intuitive thing would be to place it in that same folder, either next to the VI (or llb) or next  to the executable, depending on the execution environment.
 
Of course maybe I am overlooking something. Then there are also the issues with Windows Vista which does a "song and dance" around this because the "program files" folder is more protected from the user ( see http://zone.ni.com/devzone/cda/tut/p/id/5538) and that's where the executable typically will be located after installation. Shrug... Sorry, I don't currently run vista, so I don't know much here.

Message Edited by altenbach on 09-08-2007 11:44 PM

0 Kudos
Message 8 of 13
(3,546 Views)

You mean like this?

Of course, as you mentioned, with the data\config files being seperate from the application becoming more common (Vista, Linux), you might wish to use the Default Data Directory VI.


___________________
Try to take over the world!
0 Kudos
Message 9 of 13
(3,538 Views)
Ah, yes. OpenG seems to have implemented something similar.
 
I really should install these libraries one of these days. 😉
0 Kudos
Message 10 of 13
(3,524 Views)