The Scripting Editor in Authentic Desktop from version 2010 onwards uses a different underlying technology than earlier versions used. Consequently, scripting projects that were created with versions of Authentic Desktop prior to version 2010 might need to be modified. The following points need to be noted.
|If a previous Scripting Projects (.prj file) is opened with the new Scripting Editor (version 2010 and later), the visual layout of Forms will be migrated as faithfully as possible and scripts will be copied as they are in the .prj file. You will then need to modify the scripts to be in accordance with the new technology used by the Scripting Editor, and which is described in this documentation.|
|TheView object: The old Scripting Environment provided an artificial property named TheView that was only accessible from inside event handlers. It was used to access the Form that trigged the event (either directly or from one of its child controls). The new Scripting IDE does not provide this artificial property but instead provides the same functionality, and much more, with orthogonal built-in scripting helper functions combined with the power of the .NET framework.|
|Since all event handlers in the new Scripting Environment get a sender object as a first parameter, the source that triggered the event is always available. By calling the .NET function FindForm() on the sender object one can access the Form object easily. Alternatively (if only one Form is involved) the built-in property lastform can be used. Note that the use of lastform is not constrained to event handlers (as was the case with TheView). It can be used everywhere in script code.|
Given below is a list of methods and properties of the TheView object, each accompanied by an alternative mechanism offered by the new Scripting Environment.
The following methods were provided by the TheView object and must be migrated as explained:
In the new scripting environment the same can be achieved with: lastform.Close(); // Use .NET Form.Close()
IsFormOpen(Name as String) as Boolean
Since for .NET Forms there is a distinction between showing a Form and instantiating a Form, the previous concept does not directly translate. Instead the user can ask if a certain Form is currently shown. For example:
var objFormPencilSelector = CreateForm("PencilSelector");
var objFormColorSelector = CreateForm("ColorSelector");
// Anywhere in code ...
FormFind(Name as String) as Object
The new Scripting Environment allows you to instantiate more Forms of the same kind. In the old Scripting Environment each Form could only exist once (as a Singleton). Thus there is no equivalent of FormFind(). In the new Scripting Environment.
OpenDoc(File as String)
The same can be achieved with: Application.OpenDocument( File as String )
This corresponds to the built-in function doevents() which processes all Windows messages currently in the message queue.
RunClick(), RunInitialize(), RunTerminate()
There is no direct replacement for these methods. Call the corresponding handlers directly instead.
The following properties were provided by the TheView object and must be migrated as explained:
ToolTipText as String
To use tooltips in the new scripting environment, the .NET infrastructure can be used. This allows fine-grained control of tooltip behaviour (adjusting delays, when to show, etc). For example, to provide tooltips for a Form with two controls, the following code could to be added to the Form's Load event handler:
//Occurs whenever the user loads the form.
function MyForm_Load( objSender, e_EventArgs )
// Create the ToolTip and associate with the Form container.
var toolTip = CLR.Create("System.Windows.Forms.ToolTip");
// Set up the delays for the ToolTip.
toolTip.AutoPopDelay = 3000;
toolTip.InitialDelay = 1000;
toolTip.ReshowDelay = 500;
// Force the ToolTip text to be displayed whether or not
// the form is active.
toolTip.ShowAlways = true;
// Set up the ToolTip text for several Controls.
"Shows the progress of the operation");
"Click Button to start the processing");
Color as Long
Since all Form/controls in the new Scripting Environment are .NET controls from the System.Windows.Forms namespace, the possibilities to modify colors, background image, fonts, and all other visual aspects are numerous. For example, every Visual Component has the properties BackColor and ForeColor to modify the visual appearance. The following handler could be used to change the color of a button at runtime:
function TestForm_Button1_Click( objSender, e_EventArgs )
objSender.BackColor = CLR.Static( "System.Drawing.Color" ).SlateBlue;
Please refer to the .NET documentation to find out more about this topic:
(C) 2019 Altova GmbH