LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Where should an XML file be placed?

All, 

 

I have a motor that uses an xml file for its configuration data. 

The VIs that communicate with this motor use a dll. This dll also reads the XML file.

When I build an application for this motor, I place the XML file in the root directory of the application and communication works fine.

When I try to run it uncompiled, I am not sure where to put this XML file.

This are the places I've tried:

 

instr.lib folder of the motor

root directory of LV.

root directly of my class.

 

Where should I put this XML file when I run the code uncompiled?

Any suggestions?

0 Kudos
Message 1 of 4
(623 Views)

@Mentana-MTL wrote:

All, 

 

I have a motor that uses an xml file for its configuration data. 

The VIs that communicate with this motor use a dll. This dll also reads the XML file.

When I build an application for this motor, I place the XML file in the root directory of the application and communication works fine.

When I try to run it uncompiled, I am not sure where to put this XML file.

This are the places I've tried:

 

instr.lib folder of the motor

root directory of LV.

root directly of my class.

 

Where should I put this XML file when I run the code uncompiled?

Any suggestions?


I would vote for anywhere but the places you listed.  This is a compiled program, so your data folder would be a good place...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 4
(609 Views)

Here is how I handle finding Data and Config folders in LabVIEW Projects that I need to run in "Programming" and "Execution" modes.

  • Assume that your Project file ("MyProject.lvproj") is in a folder called "MyProject".
  • Create sub-folder(s) \Data and \Config (you can skip the \Config if you don't plan to use it) as immediate sub-folders of \MyProject, for example, \MyProject\Data.
  • Look at the File I/O Palette, and expand "File Constants".  You want to use the function "Application Directory".  When in Development mode, it will point to the root of the Project Folder, so a Build Path with "Application Directory" on top and "Data" on the bottom will give you the path to the LabVIEW "Source" folder \MyProject\Data.  But when in Run Time System, i.e. when you click on the name you chose for the Build, it will pick up the \MyProject\Data that it created wherever you told it to build.
  • To get a Config (or other) folder similarly situated "just under" \MyProject in the "built" location, you need to add "Config" in the Destinations category in the Build Specification.  Notice that "data" (which I've been calling "Data", but case doesn't matter in Windows) is already listed under "Support Directory".

One thing to be aware of is that this gives you two sets of folders for files being used by your Project, one for when you are Developing (and testing), the other for when you are Running (possibly on a completely different computer!).  Generally, I reserve \Data for output from my Project, and don't mind keeping "separate" test files I generate during Development (which are in my "LabVIEW Data" folder) and "real data files" generated on the same, or another, computer when I really mean to collect data.  Generally, I have no reason for the "test" data files to get mixed in with the "real" ones.

 

The same thing applies to Config files, which are generally "read mostly" files.  It may well be that I'll have a "default Config" file that I'll use during Development.  If so, its contents will be copied into the \MyProject\Config folder wherever the Executable is stored, so be careful.

 

Bob Schor

0 Kudos
Message 3 of 4
(581 Views)

Do you have it as a class member?  If not, add it!  Class members don't need to be LabVIEW files.  You can add text files, XML, DLLs, anything.

 

If it's a member of a class, it gets included in any build automatically.  It also maintains links to paths.

 

So, in both an EXE and in the dev environment, if it's a member of the class, then all you have to do is look through the class members to find it:

Kyle97330_0-1717171799727.png

 

Message 4 of 4
(573 Views)