# 9.1 Script type

**Introduction**

Script is applied to realize complex control functions. HMI compile software provide powerful function, simple operation, reliable script system, the features of script are list as follow:

1\) Similar to BASIC grammatical structure;

BASIC work as the first computer language for the general public, it is easy and efficient to use.

2\) Support all of program logic control structures;

Software script supports three logic control structures: order, condition, loops. It could realize complexity procedures.

3\) Powerful function; Functions of script are divided into two types: system and custom function.

* System function: the functions that system has been predefined for users.
* Custom function: users could define a function and apply to all scripts.

1. Support variety of data format;

Script supports integer, floating, BCD code, byte, string and etc.

Scripts have two types of running

1\) Background script: Run independently during start project, screen updates have no influence and valid of all scripts.

2\) Screen script: Only run under the designated screen. Screen script start running until screen is closed or switched.

And both screen and background have four modes for script

| **Property** | **Description**                                                                                   |
| ------------ | ------------------------------------------------------------------------------------------------- |
| Initialize   | The script would be executed once during loading project.                                         |
| Close        | The script would be run once during closing HMI project.                                          |
| Timing       | The script would run under certain conditions after the HMI is started, until the condition ends. |
| Bit trigger  | Script would be repeat executed when meet the condition of bit trigger.                           |

## Initialize

**Introduction**

Initialize script divided into screen initialize script and background initialize script. Screen initialize script runs once during the initialization of screen; background initialize script runs during the loading of project.

**Operating procedures**

1. Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4XQySa5h65J0Oy%2F0.png?generation=1575368725547135\&alt=media) ![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4YqmosR3WVgZTr%2F1.png?generation=1575368725531273\&alt=media)

1. Double click \[initialize] to open script edit window, as below shows;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4ZVSgLl2UTRclU%2F2.png?generation=1575368725549224\&alt=media)

1. Enter scripts in edit window;

## Close

**Introduction**

Close script divided into screen close script and background close script. Screen close script runs once During the destroying of screen because of closing or switching; background close script runs during the closind of project (such as restart HMI, into HMI setup).

**Operating procedures**

1. Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;
2. Double click \[Close] to open script edit window;
3. Enter scripts in edit window;

## Timing

**Introduction**

The script would run for a designated time interval.

**Operating procedures of creating one**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

2\) Double click \[Timing], it would pop-up below setting window;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4_jcBI-KfaVLSz%2F3.png?generation=1575368725543108\&alt=media)

| **Property** | **Description**                                         |
| ------------ | ------------------------------------------------------- |
| Cycle        | Script runs at designated time interval, unit is 10 ms. |
| Ok           | Script created.                                         |
| Cancel       | Cancel the current script setting.                      |

3\) Enter scripts in edit window;

**Operating procedures of editing**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

2\) Select \[Timing], and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4aEHoPDR1VzhnW%2F4.png?generation=1575368725615487\&alt=media)] to modify the script execution interval;

3\) Double click selected \[Timing] to open editing window;

**Operating procedures of deleting**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4bgVp51Ma-70dW%2F5.png?generation=1575368725537827\&alt=media)

2\) Select \[Timing], and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4cCFtYF7Sr8pwA%2F6.png?generation=1575368725557398\&alt=media)] to change interval of script, it pops-up above window

3\) Select \[Yes] to execute operation or select \[No] to cancel operation;

✎**Note:**

The maximum number of timing script for each screen or background is 32.

## Trigger bit

**Introduction**

Trigger control script is that software will check whether the designated bit meet trigger condition every 20ms. Script execute once condition is met until project closed.

**Operating procedures of creating one**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

2\) Double click \[Trigger bit], it pops-up below setting window;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4dEcsc_eqQbuMK%2F7.png?generation=1575368725541561\&alt=media)

Bit address: It sets trigger address for script;

Condition: detailed information as below shows;

| **Condition** | **Description**                                                                          |
| ------------- | ---------------------------------------------------------------------------------------- |
| TRUE          | Script execute once the bit value is TRUE, it checks trigger bit every 20 ms;            |
| FALSE         | Script execute once the bit value is FALSE, it checks trigger bit every 20 ms;           |
| Bit changed   | Execute once the trigger bit switches state;                                             |
| Rising        | Script execute once the bit value from FALSE to TRUE, it checks trigger bit every 20 ms; |
| Falling       | Script execute once the bit value from TURE to FALSE, it checks trigger bit every 20 ms; |

3\) Set trigger bit and condition, click \[OK] to open editing window;

**Operating procedures of editing**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

2\) Select \[Trigger script], and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4eRiifdD2lzEtw%2F8.png?generation=1575368725628543\&alt=media)] to change trigger bit and condition;

3\) Double click selected \[Trigger script] to open editing window;

**Operating procedures of deleting**

1\) Click \[Background script] in project manager to enter script editor screen, or click \[Screen script] in right click menu of screen to enter script editor screen;

2\) Select \[Trigger script], and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4fwJKDy5PmW_ln%2F9.png?generation=1575368725535225\&alt=media)] to change interval of script, it pops-up below window

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4grBb-KijB7nj_%2F10.png?generation=1575368725503512\&alt=media)

3\) Select \[Yes] to execute operation or select \[No] to cancel operation;

✎**Note:**

The maximum number of trigger script for each screen or background is 32.

## Background Function

**Introduction**

Global function is a collection of codes; it can be called in any script. The method reference system function;

**Operating procedures**

1\) Double click \[Background function] in project manager;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4hE6mjhoDq2-Vd%2F11.png?generation=1575368725545163\&alt=media)

2\) Set parameters;

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4iqWhd6u0RvztK%2F12.png?generation=1575368725545615\&alt=media)

| **Property**  | **Description**                                  |
| ------------- | ------------------------------------------------ |
| Function name | Function name could not be the same as existing. |
| Return type   | None, string, integer, float.                    |
| Parameter 1   | The name of parameter 1.                         |

**Operating procedures of editing**

1\) Click \[Background function] in project manager to enter script editor screen;

2\) Select Function name, and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4jatFiSwHgGHZF%2F13.png?generation=1575368725539828\&alt=media)] to change parameters;

3\) Double click selected \[Trigger script] to open editing window;

**Operating procedures of deleting**

1\) Click \[Background function] in project manager to enter script editor screen;

2\) Select Function name, and click \[![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4k90NI0FlVhpAM%2F14.png?generation=1575368725544543\&alt=media)] to change interval of script, it pops-up below window

![](https://3950998874-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpi-series-user-manual%2F-LvAGxupcpRjtZXZkX5I%2F-LvAHl4lJuapK4AgwqQD%2F15.png?generation=1575368725561898\&alt=media)

3\) Select \[Yes] to execute operation or select \[No] to cancel operation;

✎**Note:**

The maximum parameters for each function are 4, and parameter name can't be unique;
