From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-23-2009 06:12 AM
Hi ALL,
I am playing a wave file using play sound file vi. I have made the file a constant.
It runs fine. But I fear that if I give my vi and wave file to someone else to run, there may be
problems as the sound file path may not be the same as on my PC. Can I make
the path 'dynamic'?
Thanks.
Solved! Go to Solution.
04-23-2009 06:42 AM
Just make a right click on the path constant and choose "Change to control". This wil create a control on the Front Panel with the value of the constant as default.
You just need to position the control on the Front Panel to give it a nice look.
04-23-2009 07:19 AM
Another way to take care of this issue would be to put the file in a location that you know where it is. You could put it in the data folder when you make the exe and then get the vi path from the owing vi and generate the path that way.
Example:
Owining VI is in C:\program files\programx\programx.exe
You could get the path to the owing vi:
C:\program files\programx\ then add the data file path to get:
C:\program files\programx\\data\soundfile.wav
04-23-2009 07:25 AM
Hi Waldemar,
Thanks for your reply.
I did try however when I copied the folder containing the vi and wave file to
other location, the path is still showing at the old location and when I run
it gives me an error like couldn't find file.
Any other way?
Rgds.
04-23-2009 07:39 AM
Hi aestet,
Thanks for your reply.
I do know where the file is on my PC. The problem is when I give it to a customer for example,
I wouldn't know where he will place the file. Most likely it will not be the same path as my PC.
Of course unless I tell him to make the necessary folders or he has to select the path from his
PC. This is what I would like to avoid.
Is it possible for someone else to run the program on his PC and the sounds will play without having to
do this and that...?
Rgds.
04-23-2009 07:47 AM
The
File I/O >>> File Constants >>> Current VI's Path
will return the path to the VI on who's block diagram it resides.
In the development environment you can use the
File I/O >>> Stip Path
to get the folder spec of where that VI is located on disk. You can then use that folder spec along with
File I/O >>> Build Path
to develop you file spec.
Please note that in an exe you may have to use the "Strip Path" more than once to get a folder spec because the VIs in a exe are located inside the exe.
Ben
04-23-2009 07:58 AM
04-23-2009 08:04 AM
The OpenG toolkit has a function called Current VI's Parent Directory, which returns the folder where the VI is stored, you can use relative paths to build your path.
This is a proven working solution.
Ton