Admin Production ni-theme
Current Publication

MultiFileSelectPopup

LabWindows/CVI

MultiFileSelectPopup

int MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[], char title[], int restrictDirectory, int restrictExtension, int allowCancel, int *numberOfSelectedFiles, char ***fileList);

Purpose

Note Note  This function has been superseded by MultiFileSelectPopupEx. Use MultiFileSelectPopupEx to display a Windows Vista and later style dialog box.

Displays a multi-file selection dialog box and waits for the user to select a set of files or cancel.

Parameters

Input
Name Type Description
defaultDirectory char [] Initial directory.

If you enter "", the function uses the current working directory for the initial directory. If the user selects a directory, and the popup is displayed again in the application, the default directory is the user-selected directory.

Note   If you set restrictDirectory to Yes, "" is not valid for defaultDirectory. You must pass a valid directory name in this case.
defaultFileSpec char [] String that specifies which value is displayed by default in the file type list of the dialog box. For example, "*.c" causes all files with the .c extension to be displayed. LabWindows/CVI adds a new file type item if needed.

If an actual file name is specified, such as "test.c", that name appears in the file name box when the dialog box is displayed and the extension of the file, "*.c", is selected by default in the file type list.

The default file specification (spec) cannot contain a directory path.

The maximum length of the default file spec is 255 bytes.
fileTypeList char [] List of file types, separated by semicolons, to display in the file type list of the dialog box when restrictExtension is FALSE.

For example, "*.c;*.h" allows the user to select "*.c" or "*.h" from the file type list. The all files, *.*, option is always available.

You can group multiple file types under one entry in the drop-down list by enclosing the file types in parentheses and separating the file types by semicolons. You can include descriptive text along with the file types. For example, "JPEG Files (*.jpg;*.jpeg);PNG Files (*.png);*.bmp;" allows the user to see all JPEG file types at once, or to select "*.png" or "*.bmp" from the file type list.
title char [] Title of the dialog box.
restrictDirectory int Specify a nonzero value or select yes in the function panel to restrict the user from changing directories or drives.

Specify 0 or select no in the function panel to allow the user to change directories or drives.
restrictExtension int Specify a nonzero value or select yes in the function panel to limit the user to files with the default extension.

Specify 0 or select no in the function panel to allow the user to select files with any extension.
allowCancel int Specify a nonzero value or select yes in the function panel to allow the user to cancel out of the dialog box.

Specify 0 or select no in the function panel to force the user to make a selection before exiting the dialog box.
Output
Name Type Description
numberOfSelectedFiles int Number of files selected by the user.
fileList char ** Buffer that contains an array of strings, where each string is the name of one of the files selected. The last element of the array is a NULL pointer.

The buffer is automatically allocated by MultiFileSelectPopup and is accessible as an array of strings.

When you no longer need them, free each string and the array with the freefree function. The following example illustrates how to free each string in the file list and then free the file list array itself.

char **fileList = NULL, **ppc = NULL;
int numFiles;
int status;
int i;

status = MultiFileSelectPopup ("", "*.*", "", "", 0, 0, 1, &numFiles, &fileList);
if (status >= 0) {
   if (fileList) {
     /* Using for loop to iterate through selected files */
     for (i=0; i<numFiles; ++i) {
       printf ("Selected File : %s\n", fileList [i]);
       free (fileList [i]);
       fileList [i] = NULL;
     }
     /* Instead of for loop, can also do
     ppc = fileList;
     while (*ppc) {
       printf ("Selected File : %s\n", *ppc);
       free (*ppc);
       *ppc = NULL;
       ppc++;
     }
     */
     free (fileList);
     fileList = NULL;
   }
}

Return Value

Name Type Description
selectionStatus int The selection status or error codes generated during the function call.

0 VAL_NO_FILE_SELECTED
1 VAL_EXISTING_FILE_SELECTED

Negative values indicate that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later