Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, and Errors
   Dialogs, Clipboard, Platform, and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Collections
    array
    map
    data_array
   Image data
   Image stream
   Dialogs
    fileopen
    filesave
    msgok
    msgokcancel
    msgyesno
    msgpassword
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:objects:dialog_filesave


filesave

`filesave()` creates a save-file dialog object. Use it when an Expr script needs the user to choose a destination path.

Constructor

filesave()

Creates a save-file dialog.

dlg = filesave();

Properties

Property Type Description
`title` string Dialog title.
`directory` string Initial directory.
`file` string Initial file name.
`multi_select` boolean Always configured on the shared dialog object, but save dialogs ignore multi-select.

Methods

All configuration methods return the dialog object so calls can be chained.

title(text)

Sets the dialog title.

dlg = filesave().title("Save image");

directory(path)

Sets the initial directory. The path is resolved through host profile path rules.

dlg = filesave().directory("images");

file(name)

Sets the initial file name.

dlg = filesave().file("output.png");

add_filter(name, pattern)

Adds a file filter.

Arguments:

Argument Description
`name` Display name for the filter.
`pattern` File pattern, for example `*.png;*.jpg`.
dlg = filesave()
    .add_filter("PNG image", "*.png")
    .add_filter("All files", "*.*");

multi_select(enabled)

This method exists because `fileopen()` and `filesave()` share the same dialog object implementation, but save dialogs ignore multi-select.

dlg = filesave().multi_select(true);    // ignored by save dialog

on_result(callback)

Sets a callback for asynchronous result handling. The callback receives one argument: an `array` containing selected file paths. For save dialogs, the array normally contains one path.

When `on_result()` is used, `show()` displays the dialog and returns the dialog object immediately.

function save_selected(files)
{
    if (!files.empty())
    {
        print("Save to: ", files.get(0));
    }
}
 
filesave()
    .title("Save result")
    .file("result.png")
    .on_result(save_selected)
    .show();

show()

Shows the dialog.

Without `on_result()`, `show()` blocks until the dialog is closed and returns an `array` of selected paths. If the user cancels, it returns `none()`.

files = filesave()
    .title("Save image")
    .file("result.png")
    .add_filter("PNG image", "*.png")
    .show();
 
if (!files.is_none())
{
    print("Save to: ", files.get(0));
}

Previous: fileopen

Next: msgok

exprv4/reference/objects/dialog_filesave.txt · Last modified: by 127.0.0.1

Page Tools