A variable is a convenient placeholder that allows you to store a value that may change during the time your script is running. For example, you may wish to create a variable addedListItems to keep track of the number of list items you have dynamically added to a ComboBox control.
Newlook variables are global and, once created, can be accessed at any time during the current Newlook session. They are useful if you wish to keep a count or refer to a value in multiple places. For instance, you may want to create a variable module to keep track of the number of modules a user accesses when using your application.
JScript variables are created within your script and destroyed when the script execution ends. They are useful if you want to temporarily store a value or improve your scripts readability.
Newlook variables are accessible across all Newlook scripts, macros and forms.
A JScript variable's scope is determined by where you declare it. When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. This is a script-level variable, and it has script-level scope.
Newlook variables do not need to be declared, they are declared upon assignment. It is possible to use the Dim action within a macro to declare Newlook variables of a specific type or as a User Defined Type. There is no equivalent method that can be used within a script.
JScript variables can be declared with the var statement using the following syntax:
Syntax
var variable [= value] [, variable2 [ = value2], ...]
where variable
, variable2
are the names of the variables being declared and value
, value2
are the initial values assigned to the variable (optional).
Examples
var index;
var name = "Joe Bloggs";
var balance = 5000, upperLimit, lowerLimit = 100;
var pageVisited = null;
JScript is case sensitive, so naming a variable index
is different from naming it Index
. JScript variable names must follow these rules:
Unless explicitly declared using the Dim macro action, Newlook variables are Variants by default. Variants can contain numeric, string or date data as well as user-defined types and the special value Null.
JScript is a loosely-typed language, therefore JScript variables technically have no type, they have a type equivalent to the data they hold. It is possible to force the automatic conversion of a variable into a different type. Refer to the official Microsoft JScript documentation for more information about type coercion.
To assign a value to a global Newlook variable you will need to use the App.SetValue method with the following syntax:
Syntax
App.SetValue(name, value);
where name
is the name of the variable and value
is the value assigned to the variable.
Examples
App.SetValue("varName", "Amy Smith");
App.SetValue("varBalance", 50);
App.SetValue("date1", 19-01-2019);
To assign a value to a JScript variable, place the variable name on the left-hand side followed by an equal to (=) symbol and then the value on the right-hand side. Numeric values should be assigned without double quotes, string values should be enclosed within double quotes (").
name = "Joe Bloggs";
To retrieve the value of a Newlook variable you will need to use the App.GetValue method with the following syntax:
name = App.GetValue("vName");
Newlook variables are global and, once created, can be accessed at any time during the current Newlook session.
VBScript variables are created within your script and destroyed when the script execution ends.
Newlook variables are accessible across all Newlook scripts, macros and forms.
A VBScript variable's scope is determined by where it is declared. When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. The exception to this are variables declared with the Public keyword, which are available to all procedures. Refer to the official Microsoft VBScript documentation for more information on the different declaration types and their scope.
Newlook variables do not need to be declared, they are declared as variants upon assignment. It is possible to use the Dim action within a macro to declare Newlook variables of a specific type or as a User Defined Type. There is no equivalent method that can be used within a script.
VBScript variables can be declared using the Dim statement. Once declared, they can then be initialized by assigning a value to the variable.
Syntax
dim variable
where variable
is the name of the variable being declared.
Example
dim salary
salary = 30000
VBScript variable names must follow these rules:
VBScript has only one data type, Variant. A variant can hold different kinds of information and can behave differently depending on its context. In a numeric context, it behaves like a number. In a string context it will behave like a string. For more information on the Variant type refer to Microsoft's official VBScript documentation.
Unless explicitly declared using the Dim macro action, Newlook variables are also Variants by default. Variants can contain numeric, string or date data as well as user-defined types, arrays and the special value Null.
To assign a value to a VBScript variable, place the variable name on the left-hand side followed by an equal to (=) symbol and then the value on the right-hand side. Numeric values should be declared without double quotes, string values should be enclosed within double quotes ("), date and time variables should be enclosed within hash symbols (#).
Examples
name = "Amy Smith"
balance = 50
date1 = #12:30:44 PM#
To assign a value to a global Newlook variable you will need to use the App.SetValue method with the following syntax:
Examples
App.SetValue("varName", "Amy Smith")
App.SetValue("varBalance", 50)
To retrieve the value of a Newlook variable you will need to use the App.GetValue method with the following syntax:
name = App.GetValue("vName")
Working with controls in scripts | Working with arrays and dictionaries in scripts
© 2004-2021 looksoftware. All rights reserved.