addToSearchPath()

Synopsis

This function adds a library or folder to the search path. Unless there is an error, a zero is always returned. If the library or folder is already in the search path, no action is taken, so repeated calls to this function with the same input are tolerated. There are only limited circumstances where this function can be used correctly. A typical use is when your application creates new parts "on the fly", and the user is allowed to specify new folders to find potential designs.

Syntax

addToSearchPath ( path As String ) As Integer 
Argument Type Description
path String This is the library name or folder path to add to the search path.

Example 1

Intent >addToSearchPath("C:\My Designs") 
--> 0
This adds the "C:\My Designs" folder to the search path.

Example 2

Intent >addToSearchPath("testlib") 
Result: Error: The given library name has not been defined. testlib is not a defined library, cannot be added to the search path.

The library has to exist before being added to the search path.

Example 3

If pipe_type = :tube Then 
    addToSearchPath("tubelib") 
ElseIf pipe_type = :T Then 
    addToSearchPath("Tlib") 
Else 
    addToSearchPath("Endlib") 
    MakePart({design, element}) 
End If 
This code snippet has an input for the type of pipe (pipe_type) It then uses this information to add different libraries. Presumably, each library has an "element" design that is different for each library. It then instantiates this design as the new pipe_element part.

Note that this is not really a good way to have a part with a variable design. Usually, the designs are in one library, but have different names for different designs, instead of the same name in different libraries.