LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiples patterns in File Dialog


BruceMoyer wrote:
Could someone show me where this feature is documented? I've been trying to do this for as long as I've been using LabVIEW (about 13 years) and have never been able to figure out how to do this!

Bruce

 

If you are referring to the multiple patterns, it is stated in the help:

 

http://zone.ni.com/reference/en-XX/help/371361E-01/glang/file_dialog/#Inputs

 

 

pattern (all files)

Restricts the files displayed in the dialog box to those whose name matches pattern (all files). pattern (all files) does not restrict the directories displayed. The pattern matching in this VI is similar to the matching used in matching wildcards in Windows and Linux filenames. If you specify characters other than the question mark character (?) or the asterisk character (*), the VI displays only files or directories that contain those characters. You can use the question mark character (?) to match any single character. You can use the asterisk character (*) to match any sequence of one or more characters.

For example, a pattern (all files) of *.vi;test*.llb returns matches for any file with a .vi extension and any file whose filename begins with test and has a .llb extension.

To match multiple patterns, use a semicolon ( ; ) to separate the patterns. White space, such as blanks, tabs, and carriage returns, are taken literally. Avoid using white spaces unless they are part of the extension pattern. For example, if you use *.html;*.doc, the dialog box displays all files that end with .html and .doc. If you use *.html; *.doc, the dialog box displays only files that end with .html.

 

 

0 Kudos
Message 11 of 17
(2,094 Views)

That I knew about.  I was referring to the ability to have multiple selections in the "Files of type:" dropdown in the File dialog.

 

The example that MikaelH gave uses the NULL ASCII character (\00) to create addition selections.

 

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

 

I don't see info about using this strategy anywhere.

 

 

Bruce

0 Kudos
Message 12 of 17
(2,084 Views)
0 Kudos
Message 13 of 17
(2,081 Views)

This technique even works in LabVIEW 7.1 (the earliest version I have installed), which means that this isn't a newly implemented trick!

 

Bruce

Message 14 of 17
(2,076 Views)

The string looks very similar to that of the Windows OpenDialog Class; just replace the pipe with a NULL

 

 

private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
// Insert code to read the stream here.
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
0 Kudos
Message 15 of 17
(2,052 Views)

That's interesting.  Regardless, it should be added to the help and/or the functionality added to the Express VI.

 

 

Thanks,

Bruce

0 Kudos
Message 16 of 17
(2,047 Views)

This is the string format as it is put in the Windows API FileDialog structure, which this function ultimately uses under Windows. The matching with the .Net class is not coincidence, but they had to use a different charcter than \0 since .Net also treats 0 characters as string terminanation (LabVIEW doesn't as its strings contain an explicit length parameter). .Net clearly calls the Windows API too, simply replacing all pipe symbols with a 0 character just before sending it off.

 

As such this is likely is a side effect of LabVIEW not terminating on 0 characters rather than intended behaviour and what is worse it is Windows only. So documenting it would mean that they would have to implement it on non-Windows platforms too and likely they would go the route of .Net using for instance the pipe symbol for that on all platforms.

Message Edited by rolfk on 05-05-2010 12:53 AM
Rolf Kalbermatter
My Blog
Message 17 of 17
(2,033 Views)