Difference between revisions of "VS:VerifyLibraryRoutine"

From Vectorworks Developer
Jump to: navigation, search
(expand, how weird is this call...)
(use example with p routine)
Line 48: Line 48:
 
  boo := VerifyLibraryRoutine(routineName); { error }
 
  boo := VerifyLibraryRoutine(routineName); { error }
  
([[User:Orso.b.schmid|Orso]], 2015.06.14):  This can be used to test routine names suppressing warnings. Suppose you script for VW 2013 but wish to use a routine developed for VW 2014, normally the parser would rise the error "identifier not declared" since the routine is unknown (introduced later). If you wrap the routine call into an IF condition starting with VerifyLibraryRoutine this warning is suppressed. This is very useful for organizing libraries of algorithms spanning across different VW versions.
+
([[User:Orso.b.schmid|Orso]], 2015.06.14):  This can be used to test the routine in the .p files suppressing warnings. Suppose you script for VW 2013 but wish to use a routine developed for VW 2014, normally the parser would rise the error "identifier not declared" since the routine is unknown (introduced later). If you wrap the routine call into an IF condition starting with VerifyLibraryRoutine this warning is suppressed.
  
 
; Exception: the warning "The function is deprecated and should not be used" can't be suppressed! This will rise upon usage of routines listed as deprecated, for example the old dialog routines: [[VS:Vectorworks_2010_Deprecated_Functions| Deprecated for VW 2010 (10)]]
 
; Exception: the warning "The function is deprecated and should not be used" can't be suppressed! This will rise upon usage of routines listed as deprecated, for example the old dialog routines: [[VS:Vectorworks_2010_Deprecated_Functions| Deprecated for VW 2010 (10)]]
  
 
<code lang="pas">
 
<code lang="pas">
{ try this in VW 18 (2013), where the routine PythonExecute would normally rise the error "identifier not declared" }
+
{ try this in VW 15 (2010), where this routine would normally rise the error "identifier not declared" }
IF VerifyLibraryRoutine('PythonExecute') = FALSE THEN
+
IF VerifyLibraryRoutine('XMLSAXAddNodeAttr') = FALSE THEN
     AlrtDialog(Concat('No, forget it, it won''t work in this VW version'))
+
     AlrtDialog(Concat('No, forget it, it won''t work in the user''s VW version'))
 
ELSE
 
ELSE
     PythonExecute('Test.py'); { PythonExecute was introduced by VW 19 (2014) }
+
     XMLSAXAddNodeAttr(XMLHandle, nodeVal); { XMLSAXAddNodeAttr was introduced by VW 16 (2011) }
 
</code>
 
</code>
  

Revision as of 04:00, 2 February 2016

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


Description

Verifies that a procedure or function call located in a VectorScript extension is registered and available for use in scripts.

Call this function prior to using any call located in a VectorScript extension to ensure successful use of the call in a script.

(A VectorScript extension is also known as an SDK Plug-in Library. It is a plug-in that is developed using the VectorWorks SDK and the C++ language. When installed in the Plug-ins folder it provides functions that may be called from VectorScript. The VerifyLibraryRoutine function allows the script to determine if the function is available.)

FUNCTION VerifyLibraryRoutine(
routineName  :STRING) : BOOLEAN;
def vs.VerifyLibraryRoutine(routineName):
    return BOOLEAN

Parameters

routineName STRING Name of function call to be verified.

Return Value

Returns TRUE if the call is available, otherwise returns FALSE.

Remarks

(Orso, 2016.01.02):
  • The routines parsed are only those that you'll find in the VWPluginLibraryRoutines.p file. Any other will return FALSE!
  • This is the only function that doesn't accept a variable of type string. It really only accepts a routine name within quotes:
boo := VerifyLibraryRoutine('PythonExecute'); { OK }
routineName := 'PythonExecute';
boo := VerifyLibraryRoutine(routineName); { error }

(Orso, 2015.06.14): This can be used to test the routine in the .p files suppressing warnings. Suppose you script for VW 2013 but wish to use a routine developed for VW 2014, normally the parser would rise the error "identifier not declared" since the routine is unknown (introduced later). If you wrap the routine call into an IF condition starting with VerifyLibraryRoutine this warning is suppressed.

Exception
the warning "The function is deprecated and should not be used" can't be suppressed! This will rise upon usage of routines listed as deprecated, for example the old dialog routines: Deprecated for VW 2010 (10)
{ try this in VW 15 (2010), where this routine would normally rise the error "identifier not declared" }
IF VerifyLibraryRoutine('XMLSAXAddNodeAttr') = FALSE THEN
    AlrtDialog(Concat('No, forget it, it won''t work in the user''s VW version'))
ELSE
    XMLSAXAddNodeAttr(XMLHandle, nodeVal); { XMLSAXAddNodeAttr was introduced by VW 16 (2011) }

Version

Availability: from VectorWorks 9.0
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox