LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Browse Button and Path to Unconnected Network

Solved!
Go to solution

I know there are a number of ways to do this, but I'm hoping someone has an elegant solution.

I have an app with a file path control whose initial value is set from a .ini file.

Sometimes the value is to a network folder.

Sometimes the app is run on a computer without a network connection.

When those two things occur, the browse button doesn't work.  You have to type in something first; then you can browse.

Is there a trick to get the browse button to work when the current value is a path to a non-existent network?

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 1 of 8
(2,694 Views)

To paraphrase a witty comment, "If the Browse Button doesn't work if pointed to a Network Path on a machine with no Network Access, don't point it to a Network Path."  You should be able (I would think) to detect that the .ini file has a Network Path specified, and there's probably a clever way to detect if you have Network Access -- put them together with some clever logic and (as they also say,) "Bob's your Long Lost Relative".

 

Bob Schor

0 Kudos
Message 2 of 8
(2,687 Views)

Is that network path an UNC path (\\server\share\path) or simply a drive path that is mapped to a network?

 

Depending on that, for mapped drive paths you can for instance run "net use" and parse the returned information for the available paths and see if it matches yours. net use will return if a path is OK or DISCONNECTED as the first field in the list.

 

If you have UNC paths you can at least easily determine that it is a network path and then would need to try to get for instance the information for that path with one of the LabVIEW file Info functions. If that succeeds the path is valid. But if the server is not available that File Info function might take a long time to execute as it will wait on an internal timeout from the network provider.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 8
(2,668 Views)

I think the Browse button uses the same code as "File Dialog" used in the File Dialog Express VI. If you wire a UNC path to the Start path to that function, it returns Error 43, Operation Cancelled by User.

 

I would say this is a bug. The Help file says "If start path is invalid or unwired, the last directory viewed in a file dialog box initially appears in the dialog box."

 

It doesn't do this, but instead returns an error... and the wrong error at that.

 

I think if I were you I'd bake the function into an X/Y/Q control/etc and sanitize the name before running File Dialog.vi when the user clicks the Browse button. If you don't want to do a bunch of sanitizing, you could just catch error 43, then rerun File Dialog with no path.

 

(Of course, cancelling the dialog also returns error 43... ;))

0 Kudos
Message 4 of 8
(2,660 Views)
Solution
Accepted by topic author paul_cardinale

Here's the simplest thing I could come up with:

bb.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 8
(2,612 Views)

Ah... I thought you wanted it to still display the network path, but still be able to open the Browse command. (The Help indicates this should be possible. I say the behavior you found is a bug, but I doubt it'd be high priority for being fixed.)

0 Kudos
Message 6 of 8
(2,589 Views)

@BertMcMahan wrote:

Ah... I thought you wanted it to still display the network path, but still be able to open the Browse command. (The Help indicates this should be possible. I say the behavior you found is a bug, but I doubt it'd be high priority for being fixed.)


Setting the Start Path does not effect the Value (which is what is displayed).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 8
(2,580 Views)

Oh, duh. Brain fart 🙂

0 Kudos
Message 8 of 8
(2,576 Views)