Navigation: »No topics above this level« Scripting in Visual Build |
|
Windows Script integration is a powerful feature that can be used throughout your Visual Build projects. Any script language registering itself as an Active Script host engine can be used within Visual Build. VBScript and Jscript are provided by Microsoft, but other companies have created script engines for PerlScript, Python, RubyScript, etc. Please contact the vendor of the script engine for details on installing and registering the language for Active Script use.
Script code can be used for complex build rules, accessing common objects such as the Visual Build object model, FileSystemObject, Dictionary, WshShell, and MSXML within a project, creating and using custom COM objects that you have created, and more.
Script code can be entered in multiple ways:
1. | Script expressions can be entered in any field in a step where the Script Editor button is enabled and in a macro's Value field by enclosing the expression in [ ScriptExpressionHere ]. Note: to enter literal bracket characters in a field, use double bracket characters [[ ]]. |
2. | Script code can be executed in a Run Script action. |
3. | Custom script code can be attached to project and step events. |
4. | Script functions can be added in the Script Editor, and these functions will be globally available to all script code that is executed. |
5. | User actions can be implemented in script. |
Before a script code fragment, expression, or event is executed, all the script code defined in the Script Editor for that language is added to the engine. The Visual Build Application, Project, Step, and Builder automation objects are also added as named items (the Builder object is only available when building).
Unlike macros, where macros of the same name can override another based on their precedence, all the script code (Temporary, Project, Global, and System) for a language is concatenated together and added as global items that are accessible to all script code.
Script code can also create other COM objects that are available, etc. Several predefined system scripts are provided. See the Script.bld sample for ideas on the use of script within projects.
Notes on Debugging Scripts
• | When an error occurs during a build or in the Script Editor Immediate window, as much error information as possible is logged. For well-behaved script engines (VBScript seems to be best for this), this will include the source location (including event name, script editor tab, and/or step property name if they apply), line and column number, and error description, allowing for easy navigation to the erroneous code. |
• | The Script Editor Immediate window can be used to evaluate expressions, function calls, etc. |
• | You can use Builder.LogMessage in your script code to trace variable values and debug info when building. |