Core Function FileSaveDialog
From Sputnik Wiki
(Difference between revisions)
(→Return Value) |
m (1 revision) |
||
(5 intermediate revisions by one user not shown) | |||
Line 19: | Line 19: | ||
==== filter ==== | ==== filter ==== | ||
− | File type filter such as "All | + | File type filter such as "All|*.*" or "Text files|*.txt" |
==== options ==== | ==== options ==== | ||
Line 25: | Line 25: | ||
Optional; | Optional; | ||
<pre> | <pre> | ||
− | 1 = File Must Exist (if user types a filename) | + | 1 = File Must Exist (if user types a filename) -- Default FALSE |
− | 2 = Path Must Exist (if user types a path) | + | 2 = Path Must Exist (if user types a path) -- Default FALSE |
− | 4 = | + | 4 = Automatically adds an extension to a file name if the user omits the extension -- Default FALSE |
− | 8 = Prompt to | + | 8 = Prompt to overwrite -- Default FALSE |
− | + | ||
</pre> | </pre> | ||
Line 38: | Line 37: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns the file name. |
− | Failure: Returns | + | Failure: Returns null if user cancelled. |
=== Remarks === | === Remarks === | ||
Line 55: | Line 54: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $var = FileSaveDialog( "Choose a name.", @CurDir, "Scripts | + | $var = FileSaveDialog( "Choose a name.", @CurDir, "Scripts|*.spk;*.s", 8 + 4); |
// option 3 = dialog remains until valid path/file selected | // option 3 = dialog remains until valid path/file selected | ||
Latest revision as of 12:38, 14 June 2015
FileSaveDialog ( <title>, <dir>, <filter>, <options>, <default name> )
Contents |
Description
Initiates a Save File Dialog.
Parameters
title
Title text of the Dialog GUI.
dir
Initial directory selected in the GUI file tree.
filter
File type filter such as "All|*.*" or "Text files|*.txt"
options
Optional;
1 = File Must Exist (if user types a filename) -- Default FALSE 2 = Path Must Exist (if user types a path) -- Default FALSE 4 = Automatically adds an extension to a file name if the user omits the extension -- Default FALSE 8 = Prompt to overwrite -- Default FALSE
default name
Optional; File name to suggest to the user to save the file with.
Return Value
Success: Returns the file name.
Failure: Returns null if user cancelled.
Remarks
Separate the file filters with a semicolon as shown in the example.
Note: At this time, multiple groups of filters are not supported.
If default name is given, options must also be given. If none of the options are wanted, use 0 for options.
Special Windows folders (such as "My Documents") can be sometimes be set as the init dir.
Example
$var = FileSaveDialog( "Choose a name.", @CurDir, "Scripts|*.spk;*.s", 8 + 4); // option 3 = dialog remains until valid path/file selected If (!$var) { MsgBox("Save cancelled."); } Else { MsgBox("You chose " . $var); }