Release Notes > 12.2.0.0 > Updates in This Release > Other Enhancements > Multiple Library Paths
  
Multiple Library Paths
Introduction
It is common to use add-on libraries when delivering template solutions. Layout Developer also ships with two libraries out of the box. Layout Developer has always only allowed a single library location, although it was possible to specify that location using the -I command line argument.
The 12.2.0.0 release now provides a way to manage ALD’s library locations, permitting any number of location paths for ALD to gather libraries from. Not only can multiple paths be specified at start-up, but new FOM methods are provided to manage library paths once ALD is running.
When using multiple library paths, the library locations are searched in the order specified. As with existing libraries, the version number of the library will be honoured with the most recent library being used. If the same library version appears in multiple locations, the first found will take priority.
Specifying Paths on Startup
As before, the -I command line argument can be used, whether added to sargs.3ad or sargsw.3ad, your Windows shortcut or from the command line. However, in 12.2.0.0 multiple uses of -I can be used. For example, in sargw.3ad:
-I:{@}libs/
-I:C:/PTC Programs/custom/libs/
-I:C/Work/Support/Special/libs/
* 
The folder location must carry a ‘/’ character at the end!
Updating Library Paths Using JavaScript
The fLibrary object and the fApplication.libraries and fApplication.libraryPath properties were introduced in ALD 12.0.0.0, with fApplication.libraries allowing a rescan of the libraries (using the fApplication.libraries.rescan() method) and fLibrary allowing individual libraries to be loaded and unloaded via fLibrary.load() and fLibrary.unload(). This has not changed, but 12.2.0.0 has introduced a new fApplication.libraryPaths[] array and an extension to the rescan method to allow different modes of rescan.
The fApplication.libraryPaths[] array allows the developer to add or remove active library paths from the list which ALD will scan for libraries. The library paths specified by the -I command line argument will occupy the first elements in the array. If no -I argument is used, fApplication.libraryPaths[0] will be “{@}libs/” by default (where {@} is the shortcut to the install folder location path). Each element in the array is an fPath object.
So, using the example above, the fApplication.libraryPaths[] array will have three elements:
application.libraryPaths[0] = “{@}libs/” (or rather an fPath object representing this path, which would be output as “x3b2://type=appbase/libs/”)
application.libraryPaths[1] = “C:/PTC Programs/custom/libs/” (or the fPath object representing this path)
application.libraryPaths[2] = “C/Work/Support/Special/libs/” (or again, the fPath object representing this path)
Elements in the array can be managed using:
fApplication.clearLibraryPaths() — removes all paths from the application.libraryPaths[] array
fApplication.addLibraryPath(path) — adds a new library path to the application.libraryPaths[] array, where path is an fPath object representing the new library path to add
fApplication.removeLibraryPath(path) — will remove the specified library path from the application.libraryPaths[] array, where path is an fPath object in that array
Once library paths have been specified, ALD will need to be told to rescan the library paths to find the correct set of libraries to use. The fApplication.libraries.rescan() method has been extended for 12.2.0.0 to allow different scan modes. The modes are listed on the fApplication.LibraryScanModes constant and are:
fApplication.LIBRARYSCAN_NEW — the default method which represents the original way libraries were rescanned. In this mode, only new or updated libraries will be loaded. If libraries have been removed (for example, if a path has been removed from fApplication.libraryPaths[]) then these libraries will still appear in the library list as loaded.
fApplication.LIBRARYSCAN_CLOSEOLD — similar to the first mode, but if libraries are no longer present then they will be closed and removed from the list
fApplication.LIBRARYSCAN_CLOSEFIRST — this mode closes all libraries and performs a complete rescan and reload based on the library paths as though ALD was starting up from scratch. This is probably the safest mode to use to ensure all libraries are freshly loaded and any changes are applied