VS:GetFile: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
m (fixed broken example)
Line 47: Line 47:
PROCEDURE Example;
PROCEDURE Example;
VAR
VAR
fileName : STRING;
fileName : STRING;
a,b,c : INTEGER;
a,b,c : INTEGER;
BEGIN
BEGIN
GetFile(fileName);
GetFile(fileName);
IF NOT DidCancel THEN BEGIN
IF NOT DidCancel THEN BEGIN
Read(a,b,c);
Read(a, b, c);
Close(fileName);
Close(fileName);
END;
END;
END;
{Select a file for reading via a file open dialog}
RUN(Example);
END;
 
END;
</code>
RUN(Example);</code>
==== Python ====
==== Python ====
<code lang="py">
<code lang="py">

Revision as of 05:37, 7 October 2018

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

Description

Procedure GetFile displays a standard file dialog which requests the user to select a text document.

It is advisable to call DidCancel after using this procedure and check that the user did not cancel the file selection process.

PROCEDURE GetFile(
VAR fileName :STRING);
def vs.GetFile():
    return fileName

Parameters

fileName STRING Returns name of selected file.

Remarks

At least on the Mac, fileName does not set the default folder to browse. Use GetFileN if you want this functionality.

Example

VectorScript

PROCEDURE Example;
VAR
	fileName : STRING;
	a,b,c : INTEGER;
BEGIN
	GetFile(fileName);
	IF NOT DidCancel THEN BEGIN
		Read(a, b, c);
		Close(fileName);
	END;
END;
RUN(Example);

Python

def Example():
	vs.GetFile(fileName)
	if not vs.DidCancel():
		vs.Read(a,b,c)
		vs.Close(fileName)


Example()

Version

Availability: from All Versions