Get open filename: Difference between revisions

From ENIGMA
Jump to navigation Jump to search
 
Line 7: Line 7:
! Parameter !! Description
! Parameter !! Description
|-
|-
| ''filter'' || The file filters to use. The OsaScript widget systems only supports one file filter, but each file filter can support multiple masks.
| ''filter'' || The file filters to use.
|-
|-
| ''fname'' || The default filename to display in the dialog's text box. Can also be a directory if you want the dialog to open to a specific folder on initialization.
| ''fname'' || The default filename to display in the dialog's text box.
|}
|}



Latest revision as of 01:10, 19 February 2019

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);
}