The Newlook Script Editor

Newlook's script editor allows you to extend the functionality of your application.

Use the Script Editor to create scripts in either JScript or VBScript which can be executed at runtime. Scripts are more powerful than macros, because they allow you to use objects that other people have created and system components. A script can perform a range of operations, and can be as simple as saving a value in a field in a global variable, or as complex as connecting to a database and retrieving values based on current form data. Scripts can also help you to automate common manual tasks, for example, run a script that gets all the files from a file system directory.

Scripts support a wide variety of operations including conditional execution, the ability to access or modify current form data, manipulation of form and control properties (like fonts and colors), executing and communicating with other desktop applications and COM objects, error handling, mathematical calculations and text manipulation.

Supported Scripting Languages:

Newlook supports two scripting languages: JScript and VBScript.

JScript is a more powerful scripting language than VBScript, and is likely to be supported for longer. For these reasons we recommend using JScript. However if you have a lot of experience in Visual Basic then you may prefer to use VBScript. For further information on how to use these scripting languages we recommend visiting Microsoft's official VBScript or JScript documentation websites.

Common Script Editor tasks:

How are scripts executed?

Scripts are executed from top to bottom unless program flow constructs, such as “if” or “for”, are used. Scripts may also consist of functions (JScript) or procedures (VBScript), which are used to define logical components within your script. A function/procedure can be called from within the same script, from another script, or in response to a Newlook event. After the function/procedure has finished executing, control will return to the place where it was called and execution will continue from that point.

To execute a function or procedure in response to a Newlook object event, you will need to assign the script and function/procedure to the relevant OnEvent property of the object from which the event is triggered using the syntax ScriptName.FunctionName.

For example, if you wish to execute the PopulateList function in the ListActions scripts when the user clicks the drop down button of a combo box control then you would set the OnDropDown property of the combobox to ListActions.PopulateList.

Program flow constructs

Both JScript and VBScript have keywords such as for, while, if, and goto which allow you to change what code gets executed based on some condition.

Example

This example loops through an element "i" 10 times and returns the value of i to the user via a message box.

JSCRIPT:

/* Display the numbers 1 to 10 in a message box */

for(i = 1; i <= 10; i++)

{

MsgBox(i);

}

VBSCRIPT:

' Display the numbers 1 to 10 in a message box

for i = 1 to 10

MsgBox i

next

Adding Comments to your script

Comments can explain a procedure or a particular piece of code to anyone reading your script. They also allow you to disable blocks of code, which can be useful during debugging. Newlook ignores comments during script execution.

In JScript, anything on a line after double slashes (//) is considered a comment. JScript also supports multi-line commenting, which is useful when you want to comment out whole blocks of code rather than one line. To start the comment, use slash star (/*) and to end the comment use star slash (*/). By default, all comments are displayed as green text in the script editor.

In VBScript, anything on a line after a single quotation mark (') is considered a comment.

See Also

Macro Editor | Newlook object model | Working with controls in scripts | Working with variables in scripts


© 2004-2021 looksoftware. All rights reserved.