Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Brief introduction to the difference between local variables and tag names of Intouch script functions
Brief introduction to the difference between local variables and tag names of Intouch script functions
Brief introduction to the difference between local variables and tag names of Intouch script functions

If necessary, you can declare multiple local variables in Intouch scripts to store temporary or intermediate results. This can improve performance and reduce the total number of tags. You can use local variables in scripts, just like tagnames. However, there are some differences between local variables and tagnames:

Local variables are only valid within the scope of the script in which they are declared. Their values will be lost at the end of script execution. They cannot be referenced by any other scripts in the application.

Local variables have no dot fields.

Local variables are not included in the tag count.

Local variables must be declared before they can be used in scripts; Otherwise, the reference will be treated as a tagname. You can declare a local variable with the same name as the tag.

Declare local variables

You can declare local variables anywhere in the script as long as you declare them before using them for the first time. To declare a local variable, use the following statement:

DIM LocVarName as data type;

LocVarName is the name of a local variable. The name must conform to the naming convention for tagnames.

The data type is the data type of the local variable. Valid values include discrete, integer, real number and message. If this option is not specified, integers are used by default.

For each local variable to be declared, a separate DIM statement must be used. This is different from some programming languages, such as C language, which cannot define local variables continuously.

You can declare any number of local variables. This number is limited only by available memory.

example

To declare an integer variable:

Dimmylocaintvar is an integer;

To declare multiple real variables:

Dimmylocalrev1is a real number;

Fuzzy MyLocalRealVar2 is true;

The following statement is invalid:

Dimmylocalrevav1,MyLocalRealVar2 is a real number; //cannot be defined continuously.

Naming conflict between local variables and tags

You can declare a local variable with the same name as an existing tag. However, when this name is referenced in a script, local variables always take precedence over tags. For example, suppose you have an existing integer tag "iTag" and run the following script:

DIM iTag is an integer;

iTag = 20

In this case, the assignment statement only writes a value to the local variable. The value of the label with the same name remains unchanged.

The difference between local variables and tag names of Intouch script functions is introduced.