Jump to content

Multiple Patterns in LabView File Dialog


Recommended Posts

Let's see if this image looks better:

post-941-127292431924_thumb.png

How it works better...

The \00 is the NULL chracter, you have to switch to '\' Coded Display, to get it working.

This is the string you can use to tweak the File Dialog bevaviour.

*.txt;*.doc;*.html)\00*.txt;*.doc;*.html;\00Image\sfiles\s(*.png;*.jpg)\00*.png;*.jpg\00\00

I'm not sure why it works, and if it always will be supported but it's quite good feature.

//Mikael

Edited by MikaelH
  • Like 1
Link to comment

*.txt;*.doc;*.html)\00*.txt;*.doc;*.html;\00Image\sfiles\s(*.png;*.jpg)\00*.png;*.jpg\00\00

I'm not sure why it works, and if it always will be supported but it's quite good feature.

That's the format of a string which can be passed right into Windows API for a common Open/Close/Save dialog (anyone who's used Visual Basic or CMNDLG32.DLL should recognize it), so it won't be changing anytime soon. I only presume that NI works some magic in the background to ensure cross-platform compatibility, but I have no particular experience myself.

Link to comment

That's the format of a string which can be passed right into Windows API for a common Open/Close/Save dialog (anyone who's used Visual Basic or CMNDLG32.DLL should recognize it), so it won't be changing anytime soon. I only presume that NI works some magic in the background to ensure cross-platform compatibility, but I have no particular experience myself.

I haven't tried this but would strongly guess, that this is really just a Windows feature and by coincidence rather than by design. If it was designed that way they certainly would have made it more user friendly.

Link to comment
  • 13 years later...
8 hours ago, fabric said:

I've enjoyed this hack for many years, but noticed it is not working in LV2023Q1

See here for problem description: https://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-05-10-2010/m-p/4360614/highlight/true#M1280554

They have fixed a bug, is my guess. Concatenating by using null char is a huge security smell.

Multiple file types are [supposed to be] defined by using the semicolon separator. Does "*csv;*txt" not work?

 

Link to comment
27 minutes ago, X___ said:

LabVIEW's motto: Move slowly and break things!

Not really. And this is a very clear case of using an undocumented and unintended side effect of the implementation. It only worked on Windows and not any other platform and only because the person who implemented the file dialog functionality took a shortcut by passing the LabVIEW string directly to the Windows API without trying to sanitize it.

Microsoft discourages the use of the GetOpenFileName and GetSaveName APIs which originate from Windows 3.0 times starting with Windows Vista, and recommends to use the Common Item Dialog instead. My guess is that someone did recently listen to that recommendation and changed the file dialog implementation accordingly. Making sure it works the same way as documented for the old function is already hard enough, trying to also implement undocumented functionality and potential security bugs which this API had, is a bit to much asked.

Edited by Rolf Kalbermatter
Link to comment
On 3/14/2024 at 8:25 PM, Darren said:

The multiple patterns nugget was broken in LabVIEW 2023 Q1, but it works in LabVIEW 2023 Q3 and later.

I would actually suggest to implement it properly by extending the File Dialog Node. A double NULL terminated string array that is simply passed to a Windows API function is hardly a safe and proper LabVIEW datatype! 😁

And of course you saw it already coming, add support for that on Linux too 😁

  • Like 1
Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.