VS:FindFileInPluginFolder: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
(add remark about deep quirkiness of FindFileInPluginFolder)
Line 37: Line 37:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
([[User:Orso.b.schmid|Orso]] 2016.05.16): This routine behaves differently according to where the searched file is placed:
* if a file is placed in the upper level of the User/Plug-ins folder this will always be found
* if a file is placed anywhere else (for example in a subfolder within the User/Plug-ins folder or in the Workgroup/Plug-ins folder) the routine will
** find a file only at VW launch (you need to restart VW to make the file be found)
** nevertheless it will detect immediately if the searched file is missing




 
On the Mac, path will use colons instead of foreslashes as the folder delimiter.
On the Mac, path will use colons instead of foreslashes as the folder delimiter.</remark>
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
Line 57: Line 62:
RUN(Example);
RUN(Example);
</code>
</code>
==== Python ====
==== Python ====
<code lang="py">
<code lang="py">
Line 73: Line 79:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<version>
<version>
Availability: from VectorWorks12.0
Availability: from VectorWorks 12.0


</version>
</version>

Revision as of 08:01, 7 May 2016

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

Description

Searches for filename in all plug-in folders. Returns TRUE if the file is found, FALSE otherwise. If found, the result is returned in the path parameter.

FUNCTION FindFileInPluginFolder(
filename :STRING;
VAR path :STRING) : BOOLEAN;
def vs.FindFileInPluginFolder(filename):
    return (BOOLEAN, path)

Parameters

filename STRING
path STRING

Remarks

(Orso 2016.05.16): This routine behaves differently according to where the searched file is placed:

  • if a file is placed in the upper level of the User/Plug-ins folder this will always be found
  • if a file is placed anywhere else (for example in a subfolder within the User/Plug-ins folder or in the Workgroup/Plug-ins folder) the routine will
    • find a file only at VW launch (you need to restart VW to make the file be found)
    • nevertheless it will detect immediately if the searched file is missing


On the Mac, path will use colons instead of foreslashes as the folder delimiter.

Example

VectorScript

PROCEDURE Example;
VAR
filename, path :STRING;
BEGIN
filename := 'Callout.vso';
IF FindFileInPluginFolder(filename, path) 
THEN AlrtDialog(path)
ELSE AlrtDialog('Could not find file.');
END;
RUN(Example);

Python

def Example():
	filename = 'Callout.vso';
	ifFileExist, path = vs.FindFileInPluginFolder(filename) 
	if ifFileExist:
		vs.AlrtDialog(path)
	else: 
		vs.AlrtDialog('Could not find file.')
		
Example()

Version

Availability: from VectorWorks 12.0