Jump to content

RELATIVE browsing on file controls


torekp

Recommended Posts

A brief Google search turns up nothing, but I can't believe this doesn't already exist. I'm looking to place a file control on my VIs, with a browse button visible. When the user browses to (for example) user.lib\Paultext.txt, the new contents of the control should BE user.lib\Paultext.txt rather than C:\Progr ... bview 8.5\user.lib\Paultext.txt. In other words it should fill with the RELATIVE path. (Relative to Labview's home path - although having additional options for "relative to what" would be nice.) Then, I can have a default value for the file which makes sense even after I upgrade to 8.6 or move to a different computer, yet also have browse-ability.

If this doesn't exist yet, I'll make an Xcontrol, I guess.

Link to comment

QUOTE (torekp @ Feb 25 2009, 03:43 PM)

A brief Google search turns up nothing, but I can't believe this doesn't already exist. I'm looking to place a file control on my VIs, with a browse button visible. When the user browses to (for example) user.lib\Paultext.txt, the new contents of the control should BE user.lib\Paultext.txt rather than C:\Progr ... bview 8.5\user.lib\Paultext.txt. In other words it should fill with the RELATIVE path. (Relative to Labview's home path - although having additional options for "relative to what" would be nice.) Then, I can have a default value for the file which makes sense even after I upgrade to 8.6 or move to a different computer, yet also have browse-ability.

If this doesn't exist yet, I'll make an Xcontrol, I guess.

While a path can be relative in itself the browse function does not work that way directly. You could instead use a hidden control whose browse button you make visible and then monitor the Value changing and whenever it changes make the necessary absolute to relative conversion and display it in the visible path control.

There would need to be some error handling if the user decided to browse outside that directory as LabVIEWs File Select dialog can be not restricted directly to a certain subpart of the file hierarchy. Such small but rather cumbersome trivialities are probably the reason the Path control does not allow browsing relative paths.

Rolf Kalbermatter

Link to comment

The problem (at least on Windows) is that some paths are shall we say, non-relativistic: they just can't be resolved relatively. Use as many ".." tokens as you wish, but they won't be able to change a drive since the Windows file system doesn't mount drives to a navigable location, and no, My Computer doesn't count, go ahead, try to navigate there in a console. Any solution you implement would need to be aware of this limitation.

Link to comment
  • 2 weeks later...

MJE, I don't understand the problem. I have had great success translating path info using Compare Two Paths and a few minor accessories. I'm attaching the VIs (8.5) I built on top of Compare Two Paths.

Rolf, thanks for the suggestion.

Link to comment
  • 2 weeks later...

I followed Rolf's advice and came up with this Xcontrol. The VI example_relative_path shows how to use it. In addition to what's attached here, you need the VIs from my previous post.

If you put this Xcontrol in a file-reading VI, browse to an appropriate relative location, and set the default, the path stays good when you upgrade all your VIs to the next Labview version.

The State_rel_path.ctl does nothing, at this point. Maybe a future version will allow relative-to's other than Labview's home path.

Link to comment
  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.