LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to have a 6.1 path control display only the file name?

Hi!

I'd like to use a path control so that a user can select a file, say
"c:\temp\file.txt", and then only have "file.txt" appear in the
control. Is there a simple way of doing this so that the control
remembers the entire path, but only displays the filename? Or do I
have to use a string indicator that obscures the path control, except
for the browse button, and then load the name into the string? That
seems awfully klugey!

Much obliged for any assistance with this,

Scott Miller
0 Kudos
Message 1 of 9
(4,408 Views)
Well, I don't think there's a simple way to set the control to display a short name but save the full name, but here's a way that's kinda fun: use the control's tipstrip to hold the full path and use an event structure to switch back and forth between displaying the full path (for editing) and just the file name.
1. At the start of your program, set the tipstrip (using a property node) to the path (converted to a string).
2. Create an event structure.
3. On the event Value Changed for the path control, convert the new path to a string and save it to the tipstrip. Use the Path to Array of Strings function to get the file name from the last element in the array and write the file name to the path control.
4. On the event Mouse Down for the path control, read th
e tipstrip (using a property node), convert it to a path, and write it to the path control.
This way, if the user wants to edit the path, the full path is restored to the control (as soon as the user clicks on the control). After the user enters a new path, only the filename is displayed, but the full path is displayed in the tipstrip when the mouse pointer moves over the path control.
This doesn't handle the user tabbing to the control, but it might give you something to play with.
In the rest of your program, remember to read the path from the tipstrip and not directly from the control.
See the attached LabVIEW 6.1 example.
0 Kudos
Message 2 of 9
(4,408 Views)
I don't think that hiding the path control except the browse button is kludgy. Anyway. After the user has changed the path, you can strip the filename and write it back to the path control. Keep the real path value in a shift register. See the attachment.


LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 9
(4,408 Views)
The way you're running in a loop, you save the full path in the shift register for only one iteration of the loop: then it gets overwritten with the filename without the full path.
When you make a change to the path, the shift register doesn't equal the control so you save the full path from the control to the shift register and update the control to the filename-only. But the next time through the loop, the shift register has the full path and the control has the filename, so they're not equal and you overwrite the shift register with the filename, losing the full path.
0 Kudos
Message 4 of 9
(4,408 Views)
You are right. Here is the correction. The path is stripped before the comparison.


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 9
(4,408 Views)
Al, I must admit, while I understood every word in your post, in its
totality, it made absolutely no sense whatsoever!

Anyway, my original solution of using a string indicator that sits
directly on top of the path control, and is updated by its
value-changed events, works well.

I strongly suggest that NI consider updating the path control so that
users have a simple mechanism of customizing the way it displays its
value.

Scott Miller

Al S wrote in message news:<5065000000050000002BF60000-1042324653000@exchange.ni.com>...
> The way you're running in a loop, you save the full path in the shift
> register for only one iteration of the loop: then it gets overwritten
> with the filename without the full path.
> When you make a chang
e to the path, the shift register doesn't equal
> the control so you save the full path from the control to the shift
> register and update the control to the filename-only. But the next
> time through the loop, the shift register has the full path and the
> control has the filename, so they're not equal and you overwrite the
> shift register with the filename, losing the full path.
0 Kudos
Message 6 of 9
(4,408 Views)
Scott,

you are using a newsgroup server that doesn't show message with attachments so you have missed half of this thread where Al S and I have posted example VI to do what you want.

National Instruments mirrors comp.lang.labview on Developers Exchange forums. See your thread and relevant attached example here:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000598A0000&USEARCHCONTEXT_CATEGORY_0=_49_%24_6_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0

Jean-Pierre


LabVIEW, C'est LabVIEW

0 Kudos
Message 7 of 9
(4,408 Views)
What? You mean Google Groups can't do it all?

Thanks for pointing out my mistake Jean-Pierre. I should've realized
something was amiss when I saw other posts from Al S that were not
just syntactically correct, but semantically complete to boot!

My apologies Al. I checked out both of your suggestions on NI's site.
Using the tip strip in this novel manner never occurred to me! Mostly
I ignore them. Just icing on a cake for our in-house testers.

Scott


Jean-Pierre Drolet wrote in message news:<50650000000500000078F60000-1042324653000@exchange.ni.com>...
> Scott,
>
> you are using a newsgroup server that doesn't show message with
> attachments so you have missed half of this thread where Al S and I
> have posted
example VI to do what you want.
0 Kudos
Message 8 of 9
(4,408 Views)
Jean-Pierre:
Thanks for the reminder that not everyone can see the examples we post. I would not have caught on as quickly why my response wasn't clearer to Scott.
Scott:
My comment about the loop overwriting the full path in the shift register was in response to Jean-Pierre's first example, which he immediately fixed.
It would be nice to have additional options on the path control example (like filename only, or the ... abbreviation to display more of the path in the space of the control). But, as you can see from your string on top of a path, Jean-Pierre's straight-forward, easy-to-read stripping of the path, or my more complicated (but maybe more fun) use of the tip-strip, there are a lot of ways to display what you want.
0 Kudos
Message 9 of 9
(4,408 Views)