Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Under certain circumstances, it may be necessary to use a simple script during the object configuration. For example, you may enter a condition and a command expression to the touch object as shown below. The conditional and command expressions follow the format of script programming.

...

(1) Condition Expression

Operator

Function

Example

Description

&&

Logical AND

A && B

If A and B are true, the result is 1. In other cases, the result is 0.

||

Logical OR

A || B

If A and B are false, the result is 0. In other cases, the result is 1.

Less than

A < B

If A is smaller than B, the result is 1. In other cases, the result is 0.

Greater than

A > B

If A is greater than B, the result is 1. In other cases, the result is 0.

<= or =<

Less than or equal to

A <= B

If A is smaller than or equal to B, the result is 1. In other cases, the result is 0.

>= or =>

Greater than or equal to

A >= B

If A is greater than or equal to B, the result is 1. In other cases, the result is 0.

==

Equal to

A == B

If A is equal to B, the result is 1. In other cases, the result is 0.

!=

Is not equal to

A != B

If A is not B, the result is 1. In other cases, the result is 0.

 The following is an example of the conditional expression.

Example

Description

(Tag_A != 1) && (Tab_B == 10)

If the value of Tag_A is not 1 and the value of Tag_B is 10, the result is 1. In other cases, it returns 0.

Sin(Tag_A) == 1

If the sine of Tag_A is 1, the result is 1. In other cases, it returns 0.

Tag_A < 100

If Tag_A is smaller than 100, the result is 1. In other cases, it returns 0.

(Tag_A + Tag_B) < (Tag_A + Tag_C)

If the sum of Tag_A and Tag_B is smaller than the sum of Tag_A and Tag_C, then the result is 1. In other cases, it returns 0.

(2) Command Expression

In Xpanel, multiple command expressions can be used. The command expression is a special script program. You can also use the functions in the script for command expression.

...

The following is an example of a command expression.

Example

Description

Tag_A = 100;

PageOpen(“NewPage”);

Sets the value of Tag_A to 100 and opens the page named “NewPage”.

Tag_B = Tab_B + 1

Increases the value of Tag_B by 1.

Tag_A = 100;

Tag_B = 1;

RunScript MyLoop();

MakeCsv(“LogModel”,1);

Sets the value of Tag_A to 100 and Tag_B to 1, then executes the script named MyLoop(). Once the script is executed, the data logging model named “LogModel” will be saved in the SD memory as CSV.

...