Dec. 08, 2016
By default all scenario and task scripts are compiled as Visual Basic .NET 2.0 (VB .NET). For comprehensive Visual Basic .NET documentation, see http://msdn.microsoft.com/en-gb/library/2x7h1hfk.aspx.
You can choose to compile task scripts (but not scenarios) as C# 2.0. To do this, start the task script with the following string:
However, the AppDNA script editor supports syntax highlighting only for Visual Basic .NET.
Scenario and task scripts are compiled in memory to a .NET assembly. They can therefore utilize the entire .NET Framework and any other assemblies in the Global Assembly Cache (GAC). For example, you can use any of the classes available in the System.Collections.Generic namespace. (See the MSDN Library for documentation of this namespace.)
Task scripts have an automatic reference to the AppDNA.AppTitude.Scripting assembly.
You can specify assemblies by using the LoadAssembly extension syntax. For example:
If the assembly is not in the GAC, you must specify the complete path. This does not impact the use of Import with namespaces.
When the language is VB .NET, you can use the following syntax for strings:
Where xxxx is a string. Before compilation, the parser turns this into a VB .NET string literal. This makes it easier to specify strings that span multiple lines within the script than is possible using standard VB .NET syntax.
Dim s As String = <multiline_string>; '---Some vbscript Option Explicit Wscript.Echo "string" </multiline_string>
Dim s As String = "" & Microsoft.VisualBasic.Constants.vbCRLF & __ " '---Some vbscript" & Microsoft.VisualBasic.Constants.vbCRLF & _ " Option Explicit" & Microsoft.VisualBasic.Constants.vbCRLF & _ " Wscript.Echo ""string""" & Microsoft.VisualBasic.Constants.vbCRLF & _ " "
A basic Forward Path scenario script consists of a function that defines the output columns in the Forward Path report. The following example is the basic scenario that is created when you click New Scenario on the main toolbar.
Public Function ForwardPath(ByVal currentApplication As Application) As Output ' TODO: Your new Forward Path Logic definition must be defined here. ' For Help, please refer to the sample Forward Path scripts which ' have been provided. Dim myForwardpathresult As New Output() myForwardpathresult.Outcome = "Sample Outcome" myForwardpathresult.Cost = 100 myForwardpathresult.RAG = RAG.Green ForwardPath = myForwardpathresult End Function
The signature of the function is important and the function must return an Output object that defines at least one output column. If you want to associate task scripts with the scenario, you must define the Outcome output column.
Notice that an Application object is passed into the function. The function is run for every application that is currently selected and the Application object that is passed into the function represents the application that is currently being processed.
Use the Property Explorer on the right side of the Forward Path Logic Editor screen to explore the structure of the Application and Output objects. (The Output object is shown as the ForwardPathReportOutput in the Property Explorer.)
The scenario script can include additional functions that allow you aggregate application data by group and to generate report-level totals. See Grouped Forward Path reports for more information.
Task scripts must have the following form:
Imports AppDNA.AppTitude.Scripting Public Class ScriptClass Public Function Start(controller As IActionController) As TaskStatusEnum ' Do stuff Start = TaskStatusEnum.Complete End Function End Class
The names and accessibility of the class and the signature of the function are important. Beyond that, any VB .NET constructs are valid.
Click Task Script Help on the toolbar to view documentation of the AppDNA APIs that are available to task scripts.