get_open_filename(filter,fname)

From ENIGMA
Revision as of 01:10, 19 February 2019 by Time-killer-games (talk | contribs) (→‎Parameters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

Displays an "open file" dialog box. filter has the form 'name1|mask1|name2|mask2a;mask2b' where a typical mask is '*.ext'.

Parameters

Parameter Description
filter The file filters to use.
fname The default filename to display in the dialog's text box.

Return Values

string: Returns the selected absolute path and file name.

Example Call

// This example prompts the user to select a sprite to import, loads it as a sprite resource dynamically, and assigns the sprite to the calling object, if the file exists. Errors on cancel.
fname = get_open_filename("Supported Sprite Image Formats (*.png *.jpg *.jpeg *.gif)|*.png;*.jpg;*.jpeg;*.gif", "sprite.png");
if (file_exists(fname)) {
  sprite = sprite_add(fname, 0, true, false, 0, 0);
  sprite_index = sprite;
} else {
  show_error("No file selected!", false);
}