get_open_filename - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

FuncTitle|get_open_filename|filter,fname

Table of Contents

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);
  }
⚠️ **GitHub.com Fallback** ⚠️