Global JScript variables
Previous  Top  Next

Global JScript variables behave as standard global variables, it means they are visible and usable in any defined JScript. They can store and pass data actually or previously read, and thus enable processing over actual and historical data. Global JScript variables can be defined as numerical, string and array variables. Specially global variables of array type facilitate work with historical data.

Global JScritp variables are listed in a TreeView in a folder called Global JScript variables.
When adding a new variable, user right-clicks on this folder and chooses New Global JS variable item.

clip0081

Figure: Creating of new global JScript variable

Defining of the variable is designed similaraly as of Data items. User defines unique name, chooses the data type of the variable and sets its default value. If user does not define default value, it is set to zero or empty string in case of string data type. In addition user can define an array of chosen data types with a specific length. Arrays are supported for all the data types apart from string data type.

clip0082
Figure: Dialog View - global JScript variable

Following example is a demostration of possible using of global variables in computing running average over ring buffer, which represents simple filtration of a variable. Used global variables are g_aInPkts (represents an array where the values of input SNMP packets (inPkts) are stored), g_nLength (represents the length of the array), g_nPointer (represents a pointer in an array).

clip0084

Figure: Example of global JScript variable usage.

 


Send feedback on this topic.
Copyright © 2004-2013, SAE - Automation, s.r.o. (Ltd.), All rights reserved.