VS:GetFileN: Difference between revisions
m (1 revision) |
(expand) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<desc> | <desc> | ||
Returns the fully-qualified pathname of the selected file.</desc> | |||
</desc> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<def> | <def> | ||
<funcDef lang="vs"> | <funcDef lang="vs"> | ||
FUNCTION GetFileN(title :STRING; defaultFolder :STRING; mask :STRING; VAR fileName :STRING) :BOOLEAN; | FUNCTION GetFileN(title:STRING; defaultFolder:STRING; mask:STRING; VAR fileName:STRING) : BOOLEAN; | ||
</funcDef> | </funcDef> | ||
<funcDef lang="py"> | <funcDef lang="py"> | ||
Line 46: | Line 39: | ||
fileName | fileName | ||
STRING | STRING | ||
</line> | </line> | ||
</lineList> | </lineList> | ||
</params> | </params> | ||
----------------------------------------------------------------------------------------------------------- | |||
<remark> | |||
([[User:Orso.b.schmid|Orso]] 2017.01.22): Prompts for selection of a file of type "mask". The parameter "defaultFolder", if not empty, must be a posix path (with slashes). A HFS path (with colons) to the default folders can be obtained with [[VS:GetFolderPath]], you will need to use [[VS:ConvertHSF2PosixPath]] for converting it into posix. Assigns the found path to var "fileName". Mask is case sensitive. The returned path is posix. | |||
* mask = '*.vwx' allows selection of files of type .vwx | |||
* mask = '****' allows selection of any kind of files | |||
* mask = 'vwx;txt' allows range of selection (from Pat Stanford on the VS list) | |||
The GetFileN uses the SDK interface IFileChooserDialog | |||
[[VCOM:Working with File/Folder Choose Dialogs]] | |||
the ‘mask’ parameter goes as input to | |||
fileChooser->SetDefaultExtension(mask); | |||
[[VCOM:VectorWorks:Filing:IFileChooserDialog::SetDefaultExtension]] | |||
(MaKro, 2016.10.18): | |||
:Mask format change in VW2016 on a Windows 7 machine | |||
:Python mask example: '*.txt' if VW-Version < 2016 else 'txt' | |||
</remark> | </remark> | ||
Line 67: | Line 73: | ||
<code lang="pas"> | <code lang="pas"> | ||
PROCEDURE Example; | PROCEDURE Example; | ||
VAR | VAR | ||
fileName, title :STRING; | |||
defaultFolder :STRING; | |||
mask :STRING; | |||
BEGIN | BEGIN | ||
title := 'Select the object library file...'; | |||
defaultFolder := ''; | |||
mask := '*.vwx'; | |||
fileName := 'Drafting Tools.vwx'; | |||
IF GetFileN(title, defaultFolder, mask, fileName) THEN | |||
AlrtDialog(fileName); | |||
END; | |||
END; | |||
RUN(Example);</code> | RUN(Example);</code> | ||
</sample> | |||
</ | ----------------------------------------------------------------------------------------------------------- | ||
<seeAlso></seeAlso> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<version> | <version> | ||
Availability: from | Availability: from Vectorworks 2014 | ||
</version> | </version> | ||
</vwDoc> | </vwDoc> |
Revision as of 05:08, 22 January 2017
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Returns the fully-qualified pathname of the selected file.
FUNCTION GetFileN(
title :STRING;
defaultFolder :STRING;
mask :STRING;
VAR fileName :STRING) : BOOLEAN;
def vs.GetFileN(title, defaultFolder, mask): return (BOOLEAN, fileName)
Parameters
title STRING defaultFolder STRING mask STRING fileName STRING
Remarks
(Orso 2017.01.22): Prompts for selection of a file of type "mask". The parameter "defaultFolder", if not empty, must be a posix path (with slashes). A HFS path (with colons) to the default folders can be obtained with VS:GetFolderPath, you will need to use VS:ConvertHSF2PosixPath for converting it into posix. Assigns the found path to var "fileName". Mask is case sensitive. The returned path is posix.
- mask = '*.vwx' allows selection of files of type .vwx
- mask = '****' allows selection of any kind of files
- mask = 'vwx;txt' allows range of selection (from Pat Stanford on the VS list)
The GetFileN uses the SDK interface IFileChooserDialog
VCOM:Working with File/Folder Choose Dialogs
the ‘mask’ parameter goes as input to fileChooser->SetDefaultExtension(mask);
VCOM:VectorWorks:Filing:IFileChooserDialog::SetDefaultExtension
(MaKro, 2016.10.18):
- Mask format change in VW2016 on a Windows 7 machine
- Python mask example: '*.txt' if VW-Version < 2016 else 'txt'
Example
PROCEDURE Example; VAR fileName, title :STRING; defaultFolder :STRING; mask :STRING; BEGIN title := 'Select the object library file...'; defaultFolder := ''; mask := '*.vwx'; fileName := 'Drafting Tools.vwx'; IF GetFileN(title, defaultFolder, mask, fileName) THEN AlrtDialog(fileName); END; RUN(Example);
Version
Availability: from Vectorworks 2014