4D v14.3Select document |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Select document
|
Select document ( directory ; fileTypes ; title ; options {; selected} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
directory | Text, Longint |
![]() |
• Directory access path to display by default in the document selection dialog box, or • Empty string to display default user folder (“My documents” under Windows, “Documents” under Mac OS), or • Number of the memorized access path |
|||||
fileTypes | Text |
![]() |
List of types of documents to filter, or "*" to not filter documents | |||||
title | Text |
![]() |
Title of the selection dialog box | |||||
options | Longint |
![]() |
Selection option(s) | |||||
selected | Text array |
![]() |
Array containing the list of access paths + names of selected files | |||||
Function result | String |
![]() |
Name of selected file (first file of the list in case of multiple selection) | |||||
The Select document command displays a standard open document dialog box which allows the user to set one or more files and returns the name and/or full access path of the selected file(s).
The directory parameter indicates the folder whose contents are initially displayed in the open document dialog box. You can pass three types of values:
Note: This mechanism is the same as the one used by the Select folder command. The numbers of the memorized pathnames are shared by both commands.
Pass the type(s) of file(s) that can be selected in the open file dialog box in the fileTypes parameter. You can pass a list of several types separated by a ; (semi-colon). For each type defined, a row will be added in the type choice menu of the dialog box.
If you do not want to restrict the files displayed to one or more types, pass the "*" (star) or ".*" string in fileTypes.
Pass the label that must appear in the dialog box in the title parameter. By default, if you pass an empty string, the label “Open” is displayed.
The options parameter allows you to specify advanced functions that are allowed in an open file dialog box. 4D provides the following pre-defined constants in the System Documents theme:
Constant | Type | Value | Comment |
Alias selection | Longint | 8 | Authorizes the selection of shortcuts (Windows) or aliases (Mac OS) as document. By default, if this constant is not used, when an alias or shortcut is selected, the command will return the access path of the targeted element. When you pass the constant, the command returns the path of the alias or shortcut itself. |
File name entry | Longint | 32 | Allows user to enter a file name in a 'Save as' dialog box. No file is saved and it is up to the developer to create a file in response to this action (the Document system variable is updated). In this context, the directory parameter may contain the path to a file instead of a directory. The file name will be used as the suggested file name in the Save as text field. The parent directory will be used as default path. |
Multiple files | Longint | 1 | Authorizes the simultaneous selection of several files using the key combinations Shift+click (adjacent selection) and Ctrl+click (Windows) or Command+click (Mac OS). In this case, the selected parameter, if passed, contains the list of all selected files. By default, if this constant is not used, the command will not allow the selection of multiple files. |
Package open | Longint | 2 | (Mac OS only): Authorizes the opening of packages as folders and thus the viewing /selection of their contents. By default, if this constant is not used, the command will not allow the opening of packages. |
Package selection | Longint | 4 | (Mac OS only): Authorizes the selection of packages as entities. By default, if this constant is not used, the command will not allow the selection of software packages as such. |
Use sheet window | Longint | 16 | (Mac OS only): Displays the selection dialog box in the form of a sheet window (this option is ignored under Windows). Sheet windows are specific to the Mac OS X interface which have graphic animation (for more information, refer to the Window Types section). By default, if this constant is not used, the command will display a standard dialog box. |
If you do not want to use an option, pass 0 in the options parameter.
The optional selected parameter allows you to get the full access path (access path + name) of every file selected by the user. The command creates, sizes and fills the array according to the user selection. This parameter is useful when the Multiple files option is used or when you want to find out the access path of the selected file (simply take the name of the file returned by the command from the value of the array). If no file is selected, the array is returned empty.
Note: Under Mac OS, a selected package is considered as a folder. The pathname returned in the selected array includes a final ":" character. For example: Disk:Applications:4D:4D v11.4:US:4D Volume Desktop.app:
The command returns the name (name + extension under Windows) of the selected file. If several files are selected, the command returns the name of the first file in the list of selected files. The list of files can be obtained in the selected parameter. If no file is selected, the command returns an empty string.
This example is used to specify a 4D data file:
C_LONGINT($platform)
PLATFORM PROPERTIES($platform)
If($platform=Windows)
$DocType:=".4DD"
Else
$DocType:="com.4d.4d.data-file" `UTI type
End if
$Options:=Alias selection+Package open+Use sheet window
$Doc:=Select document("";$DocType;"Select the data file";$Options)
Creation of a custom document by user:
$doc:=Select document(System folder(Documents folder)+"Report.pdf";"pdf";"Report name:";File name entry)
If(OK=1)
BLOB TO DOCUMENT(Document;$blob) // $blob contains document to record
End if
If the command has been correctly executed and a valid document was selected, the system variable OK is set to 1 and the system variable Document will contain the full access path of the selected file.
If no file was selected (for example, if the user clicked on the Cancel button in the open file dialog box), the system variable OK is set to 0 and the system variable Document will be empty.
Product: 4D
Theme: System Documents
Number:
905
Modified: 4D v11 SQL
Modified: 4D v13
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)
Inherited from : Select document ( 4D v11 SQL Release 6)