LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple question on file names

I have a simple-minded question! Using "Write To Spreadsheet File" it's
prompting me for file name with a dialog box? How do I specify the name
(and path) of the file on the diagram? (so it will run unattended)

Of course, there is a pin marked "File Path (dialog if empty)" that sure
looks like the way to specify the file name... (and give a dialog box, if
nothing is connected to this pin) however! It won't accept a string....
it's a green pin. (sorry to ask such a dumb question!)

Direct email if fine... just remove the 'ABC' thanks, David
0 Kudos
Message 1 of 3
(2,840 Views)
This is not a dumb question at all.

Yes, if you want to save your file without the file dialog you have to provide the file path to that pin. However, since LabVIEW uses as specific data type (green) for file paths, you cannot wire a string directly to that pin.

What you need to do is to build your file path. You can do this many ways; one way is that you set it up as a string and then convert the string to a file path using the String to Path function under the String/Array/Path conversions. However, a better way could be to use a path constant (e.g. the current VIs path) and modify it to fit your needs. That will allow more flexibility if your application is copied to another computer with a different file structure. Path constants can be found under the File I/O.
There you also have Build path and Strip path that are useful for modifying paths.

I attached a simple example, Save File.vi, that show how it works. Hope this helps. /Mikael
0 Kudos
Message 2 of 3
(2,840 Views)
> I have a simple-minded question! Using "Write To Spreadsheet File" it's
> prompting me for file name with a dialog box? How do I specify the name
> (and path) of the file on the diagram? (so it will run unattended)
>
> Of course, there is a pin marked "File Path (dialog if empty)" that sure
> looks like the way to specify the file name... (and give a dialog box, if
> nothing is connected to this pin) however! It won't accept a string....
> it's a green pin. (sorry to ask such a dumb question!)
>

The green wire is a path datatype. On the file I/O palette, there is
a function constant, some functions for manipulating paths, etc.

The easiest way to get an input on pretty much anything is to popup
on the terminal/pin and select Create Control or constant.
LV will
automatically create a control of the type on the terminal.

Greg McKaskle
0 Kudos
Message 3 of 3
(2,840 Views)