Contents Previous Next Subchapters

Dialog For Choosing File Names
Syntax chfile(captiondefaultdescriptionextension)
See Also openfile , savefile

Description
Displays a browser dialog in which the user chooses a file. This routine differs from the openfile , savefile routines in that the browser will start in the directory where the default file is located.

The character row vector caption specifies the caption for the dialog. The caption must begin with one of the following words: "Read", "Load", "Open", "Write", "Store", or "Save". The character row vector default specifies the default file name. This name may contain the entire path that specifies the file from the root directory, or it may specify the file relative to the current directory. If the second character of default is a colon, the first character in default specifies a disk drive. No other character in default can be a colon. The character row vector description describes the type of files that the argument extension refers to (for example description might equal "data files"). The character row vector extension specifies a file extension (for example "*.dat"). The list of files displayed in the dialog is limited to those with this extension.

The return value of chfile is a character row vector containing the name of the file that the user chooses. This is a complete path name including the disk drive. If the user chooses the Cancel button in the dialog, an empty character row vector is returned; i.e., its column dimension is zero.

Example
If you enter
     caption     = "Load Program"
     default     = "\omwin\autoexec.oms"
     description = "O-Matrix Source"
     extension   = "*.oms" 
     chfile(caption, default, description, extension)
O-Matrix will display a browser dialog that lists the files in the \omwin directory that have the mat extension. If you choose a file, its name will be printed in the command window.

Reference
The extension parameter must begin with the character * followed by the character . and it must contain at least one more character. You can specify all files by using the extension *.*.