LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get LabVIEW to find a file?

Hello,
 
I want to do something so basic and dumb that there must be an easy way to do it, but I'm not finding it.  I have an application which opens several parameter files, reads them, and does various things with their contents.  The application will eventually be built into an executable.  Some of the parameter files have .dat extensions.  One of them is a .pln extension.  They're all just text files.
 
I know that the parameter files I will need will always be somewhere on the computer's local drive...but they won't always be in the same place, so I can't use absolute file paths.  I need to be able to find those files, open them,  read them, etc.
 
I tried using the "Recursive File List" vi to do the search (with the intent being to have it list all the files and then do a search through the resulting array for the files I actually want), but it gets all pissed off when it tries to search the C:\ drive and finds files where the user doesn't have the necessary file permission.  Then it quits and doesn't tell anyone anything.
 
Help?  Anyone?
 
Thanks!
d
0 Kudos
Message 1 of 9
(3,598 Views)
It doesn't seem very efficient to have to search the entire C:\ drive each time to look for these files. The search itself (setting aside the permissions issue) will be very time-consuming. If you cannot limit the directories where something can be found then I would suggest using an indexing service that is always running on the computer so that your app will just need to query the indexing service to find a file. The indexing service works by creating a database. Windows XP comes with an indexing service, and there's an API for it that you can interface to. It's quite clumsy, though. Google Desktop would be another option. It also has an API.
Message 2 of 9
(3,587 Views)
So it turns out that the files I need will always reside in the same directory as the calling program.  It's relatively straightforward to query the calling directory for an executable, is it not?  I know it can be done for a vi, does it work the same way for an exe?  Once I have that information, I just have to search that directory until I find the files I want.
0 Kudos
Message 3 of 9
(3,569 Views)
If you are in the run time environment you usually need to strip the path a second time to remove the exe file name out of the path.

If your vi is already running in a .llb file or a subdirectory there will be no difference as you will also need to strip the directory twice in the development environment to get the top level folder.

Hope that makes sense.


_______________________________________
Systems Test Engineer
Certified LabVIEW Architect (CLA)
Message 4 of 9
(3,559 Views)

Thanks Karissa...I did know about the double-stripping for run-time environments, so I've accounted for that.  I just used a property node to determine whether I was in development mode or run-time mode, and did the double-strip or not based on that.  Seems to work fine.

A totally unrelated question:  I have a strip chart that I'm using to display some data.  It displays a 5-point array every second.  Right now the x-axis is in points, not seconds (i.e. instead of the x-axis reading "10", to indicate 10 seconds of data, it reads "50", to indicate 50 points).  Is there a quick and easy way to get the x-axis to display seconds, or do I have to use an xy graph instead of a strip chart?  I do want a strip-chart update.

Thanks everyone!

d

0 Kudos
Message 5 of 9
(3,549 Views)

Hi DianeS,

you can use the factor and offset fields from the chart option. See the attached example.

Mike

0 Kudos
Message 6 of 9
(3,535 Views)

Hi Mike,

Unfortunately your example wasn't very helpful.  All it did was clear the chart at the beginning (which I know how to do), then plot a single point versus time.  So basically, the time elapsed and the number of points were still the same.  I know how to do that -- the chart sort of does that by default, which is specifically what I'm trying to change.  I'm trying to plot where the time elapsed (in seconds) and the number of points plotted (per second) are not the same.

Was that the example you meant to attach?  It didn't show either of the properties you mentioned.  I'll look for them, though (I assume I can find them in the property nodes for my chart) and see if I can get it to work.

Thanks!

d

0 Kudos
Message 7 of 9
(3,515 Views)
Have you looked through the shipping examples? A very basic one is called Real-Time Chart.
Message 8 of 9
(3,512 Views)

Actually, although the sample code wasn't helpful, the post was -- I found the "multiplier" property node, wired an appropriate value to it (in this case, [1/sample rate]/10 -- the divide by 10 is because I'm decimating the data before displaying it), and ta-da!  The x-axis now displays exactly the way I want it to.  I was sure there had to be an easy way to do it, and indeed there is.

Thank you, everyone, for the help!

d

0 Kudos
Message 9 of 9
(3,473 Views)