05-04-2010 09:55 AM
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.
|
05-04-2010 10:19 AM
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
05-04-2010 10:20 AM
It took me a while to find it, but if you are a Mac user, there was a bug with multiple patterns...
05-04-2010 10:25 AM
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
05-04-2010 01:42 PM
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);
}
}
}
05-04-2010 01:50 PM
That's interesting. Regardless, it should be added to the help and/or the functionality added to the Express VI.
Thanks,
Bruce
05-04-2010 05:51 PM - edited 05-04-2010 05:53 PM
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.