Core Function FileOpenDialog
From Sputnik Wiki
(Difference between revisions)
(→options) |
|||
Line 26: | Line 26: | ||
<pre> | <pre> | ||
[optional] Dialog Options: To use more than one option, use a + sign to separate them (eg: 1 + 4). | [optional] Dialog Options: To use more than one option, use a + sign to separate them (eg: 1 + 4). | ||
− | 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 = Allow MultiSelect | + | 4 = Allow MultiSelect -- Default FALSE |
− | 8 = Automatically adds an extension to a file name if the user omits the extension | + | 8 = Automatically adds an extension to a file name if the user omits the extension -- Default FALSE |
</pre> | </pre> | ||
Line 38: | Line 38: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns the | + | Success: Returns all the chosen files as an array. |
Failure: Returns empty string. | Failure: Returns empty string. | ||
Line 45: | Line 45: | ||
Separate the file filters with a semicolon as shown in the example. | Separate the file filters with a semicolon as shown in the example. | ||
− | |||
− | |||
If default name is given, options must also be given. If none of the options are wanted, use 0 for options. | If default name is given, options must also be given. If none of the options are wanted, use 0 for options. | ||
Line 55: | Line 53: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | + | $var = FileOpenDialog($message, @WinDir, "Image Files|*.bmp;*.png", 4 + 1 ); | |
− | + | ||
− | $var = FileOpenDialog($message, @WinDir, " | + | |
− | + | ||
If (!$var) | If (!$var) | ||
{ | { | ||
Line 65: | Line 61: | ||
Else | Else | ||
{ | { | ||
− | $var = | + | $var = Join($var, @CRLF); |
MsgBox("You chose $var"); | MsgBox("You chose $var"); | ||
} | } |
Revision as of 18:24, 8 December 2011
FileOpenDialog ( <title>, <dir>, <filter>, <options>, <default name> )
Contents |
Description
Initiates a Load 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;
[optional] Dialog Options: To use more than one option, use a + sign to separate them (eg: 1 + 4). 1 = File Must Exist (if user types a filename) -- Default FALSE 2 = Path Must Exist (if user types a path) -- Default FALSE 4 = Allow MultiSelect -- Default FALSE 8 = Automatically adds an extension to a file name if the user omits the extension -- Default FALSE
default name
Optional; File name to suggest to the user to save the file with.
Return Value
Success: Returns all the chosen files as an array.
Failure: Returns empty string.
Remarks
Separate the file filters with a semicolon as shown in the example.
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 = FileOpenDialog($message, @WinDir, "Image Files|*.bmp;*.png", 4 + 1 ); If (!$var) { MsgBox("No File(s) chosen"); } Else { $var = Join($var, @CRLF); MsgBox("You chose $var"); }