LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Abbreviated Path to String?

I have an app which I'd like to show file paths in a string control but fix the path to no more than 80 characters.  I noticed that the new Path Control has a path abbreivation feature where it will put ellipsis (...) to try its hardest to always show the file name and then abbreviate the leading path to make it fit within the bounds of the control.   I'd like to leverage this logic in a VI by specifying a numeric as the fixed width value and input an arbitrarily long string and/or path into a VI and out comes the abbreviated version with the width I specified. 

Does something like this already exist? If not, can I somehow cheat it by creating a hidden path control, specifiying its width, setting its value then reading out what LabVIEW did to abbreviate it?


0 Kudos
Message 1 of 3
(3,150 Views)

@SiegeX wrote:

If not, can I somehow cheat it by creating a hidden path control, specifiying its width, setting its value then reading out what LabVIEW did to abbreviate it?


You can read out the abbreviated string of a path control using the path.text.text property.

 

 

0 Kudos
Message 2 of 3
(3,140 Views)

Those of us stuck in older LV can resort to a helpful Windows API function.

 

CompactString.png

 

Not too hard to roll your own, I usually use Path to Array and then lop off the middle elements making certain to leave the volume and the filename intact.  Usually not a problem unless you go crazy with the filenames.

 

 

Message 3 of 3
(3,125 Views)