dlg_save: Modal dialog to select a file to save to.

View source: R/dlg_save.R

dlg_saveR Documentation

Modal dialog to select a file to save to.

Description

Select an existing file, or create a new one to save data.

Usage

dlg_save(
  default = "untitled",
  title = "Save file as",
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

dlgSave(
  default = "untitled",
  title = "Save file as",
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

## S3 method for class 'gui'
dlg_save(default, title, filters = dlg_filters["All", ], ..., gui = .GUI)

## S3 method for class 'textCLI'
dlg_save(default, title, filters = dlg_filters["All", ], ..., gui = .GUI)

## S3 method for class 'nativeGUI'
dlg_save(
  default,
  title,
  filters = dlg_filters["All", ],
  rstudio = getOption("svDialogs.rstudio", TRUE),
  ...,
  gui = .GUI
)

Arguments

default

The default file to start with (use /dir/* or /dir/*.* to start in a given directory, but without predefined name).

title

A title to display on top of the dialog box.

filters

A specification of file filters as a nx2 matrix, or a character string with even number of items. First items is the label, second one is the filter. See dlg_filters for examples. This is currently ignored on MacOS, since such kind of filter is defined differently there.

...

Pass further arguments to methods.

gui

The modified 'gui' object is returned invisibly. The chosen file, or an empty string (if the "cancel" button was clicked or confirmation was cancelled) is placed in gui$res (see example). For existing files, confirmation is always asked!

rstudio

Logical. Should 'RStudio' dialog boxes automatically be used if available? If FALSE, force using OS dialog boxes, but only in 'RStudio Desktop' (ignored in 'RStudio Server'). Can be changed globally with options(svDialogs.rstudio = TRUE|FALSE). TRUE by default.

Note

In case the file already exists, the user is prompted to confirm he wants to overwrite the existing file. If he clicks 'Cancel', then the return is an empty string. The 'RStudio' version of this dialog box currently ignores the filters = argument.

See Also

dlg_open(), dlg_dir()

Examples

## Not run: 
# Choose one R filename to save some R script into it
dlg_save(title = "Save R script to", filters = dlg_filters[c("R", "All"), ])$res

## End(Not run)

SciViews/svDialogs documentation built on May 16, 2022, 1:22 p.m.