VS:GetFileN

From Vectorworks Developer
Revision as of 14:30, 12 August 2013 by Root (talk | contribs) (1 revision)
Jump to navigation Jump to search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Prompts for the selection of a file. Returns the fully qualified pathname of the selected file. Returns false if the user clicked the Cancel button.

Valid mask values include:

*.ext (where ext is the actual extension, such as *.txt)
TEXT (Mac text file)
MCD (Mac VectorWorks file)
**** (all files, either platform)
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 Output parameter.

Remarks

On OSX, the defaultFolder has to be just the folder, but on OS9 or on Windows, it can include a filename. Either way, if a filename is present, the file does not get selected in the dialog, so don't bother casing this for platforms -- just make sure that defaultFolder just has the name of a folder.

On OSX, GetFileN expects a fully qualified name, using foreslashes, such as '/Applications/VectorWorks'.

Example

PROCEDURE Example;
VAR
   major, minor, maintenance, platform :INTEGER;
   title, defaultFolder, mask, fileName: STRING;
BEGIN
   title := 'Select something...';
   GetVersion(major, minor, maintenance, platform);
   IF platform = 1 THEN BEGIN
      defaultFolder := '/Applications';
   END ELSE BEGIN
      defaultFolder := 'C:\Program Files';
   END;
   mask := '*.txt';
   IF GetFileN(title, defaultFolder, mask, fileName)
      THEN AlrtDialog(fileName);
END;
RUN(Example);

Version

Availability: from All Versions

This is drop-in function.