# uigetfile

## Purpose

Retrieve name of a file to open through a dialog box.

## Synopsis

    [filename,pathname] = uigetfile('filterSpec','boxTitle',x,y)

## Description

`[filename,pathname] = uigetfile('filterSpec','boxTitle',x,y)` displays a dialog box in which you can fill in or select the filename and path strings, where

- `filterSpec` filters the types of files initially displayed in the dialog box. For example, `'`*`.m'` lists all MATLAB M-files within a selected directory.
- `boxTitle` is a string containing the title of the dialog box.
- `x` is the x-position, in pixels, of the lower-left corner of the dialog box (not supported on all systems).
- `y` is the y-position, in pixels, of the lower-left corner of the dialog box (not supported on all systems).
  All parameters are optional, but if one is present, all preceding parameters must also be present. A successful return occurs only if the file exists. If you select a file that does not exist, the function displays an error message and control returns to the dialog box. You can then enter another filename, or press the Cancel button.

  `filename` is a string containing the name of the file selected in the dialog box. If you press the Cancel button or if any error occurs, `filename` is set to 0.

  `pathname` is a string containing the path of the file selected in the dialog box. If you press the Cancel button or if any error occurs, `pathname` is set to 0.

  ## Examples

  An example of `uigetfile`'s operation on one platform is

      [fname,pname] = uigetfile('*.m','Example Dialog Box')

      fname =
      banana.m

      pname =
      /amnt/u/home2/pat

  The exact appearance of the dialog box depends on your windowing system.

  ## See Also

      uiputfile

  (c) Copyright 1994 by The MathWorks, Inc.