9.2 Script usage
Introduction
Script can make project more convenient and flexible. Script is useful in realizing complex HMI function. If the script is used improperly, it may affect the efficiency of entire project. So pay attention to the follow issues:
1) Do not use too much script loops, if the script loops that execute too many times; it might influence the efficiency of HMI.
2) In the cycle scripts, avoid using external register, due to the relatively slow serial communication, frequent access to external registers may cause the execution of scripts severely reduced, even influence the screen respond efficiently. There is fine to use internal register.
3) The maximum script length is 512 rows.
This section describes how to edit scripts and use some of the accompanying tools and features of the script editor.
9.2.1 Script Access to Device
Software script supports an efficiency way to access the device address by using symbol @.
Writing | Meaning | Examples |
@B_;@b_; | Access designated bit address | @B_I0.0: access bit address I0.0 @b_HDX0.0: access bit address HDX0.0 |
@W_;@w_; | Access designated word address HMI connect more than automatic control devices, "#"stands for choosing number before the symbol,":" stands for accessing the station number before symbol. Access the first protocol without "#", access default station number1 without":". | @W_IW0: access word address IW0 @b_HDW0:access word address HDW0 |
@B_(the number of protocol connection)#(station number):address | @B_2#2:I0.0:access the bit address I0.0, with the connection number 2 and station number 2; @B_I0.0:access to bit address I0.0; |
The script can access with the device though: write and read.
For example
If @B_HDX0.0 = 1 then 'read the value from address HDX0.0.
@B_HDX0.0 = 0 'write 0 to address HDX0.0
Else
@B_HDX0.0 = 1 'write 1 to address HDX0.0
Endif
@W_QW0 = @W_QW0 + 1 'read data from address QW0, add 1 to this value then write to address QW0.
9.2.2 Grammar Checking
Operating procedures
2) System does not prompt grammar error if grammar is correct, or system will list all errors;
3) Check error information, and modify errors;
Error information
1) Identifier *** contains invalid characters
2) Attempt to redeclare sub ***
3) Attempt to redeclare function ***
4) Attempt to use reserved word *** as identifier
5) Attempt to use type *** as identifier
6) Unexpected ')' while parsing arguments for function ***
7) Could not parse expression (one of the arguments of function ***)
8) Could not parse arguments of ***
9) Too many arguments for function ***
10) Not enough arguments for function ***
11) '(' expected after sub name ***
12) Unexpected '(' while parsing arguments for sub ***
13) Could not parse expression (one of the arguments of sub ***)
14) Could not parse arguments of ***
15) Too many arguments for sub/function ***
16) Not enough arguments for sub/function ***
17) Could not parse expression
18) '(' expected after function name ***
19) Unexpected use of sub *** as a part of expression
20) Illegal statements preceding subs/functions declaration
21) Unexpected end of file while looking for 'endsub'
22) End of line expected after 'else'.
23) End of line expected after 'endif'.
24) End of line expected after 'next'.
25) End of line expected after 'wend'.
26) 'while', 'until' or end of line expected afte r'do'.
27) Could not parse expression after 'while'
28) Could not parse expression after 'until'
29) 'do' without 'loop'
30) Sub *** contains invalid character'@'
31) Sub *** already declared
32) Function *** already declared
33) Sub name expected after 'sub'
34) Function name expected afte r'function'
35) Variable name expected
36) Argument *** contains invalid character '@'
37) 'integer', 'floating' or 'string' expected
38) ''',' or ')' expected
39) 'endsub' without 'sub'
40) 'end function' without 'function'
41) End of line expected after 'beep'
42) 'dim' unexpected here
43) Variable name expected after 'dim'
44) 'as' expected after variable name
45) 'integer' 'floating' or 'string' expected after 'as'
46) ',' or end of line expected after type in dim statement
47) Could not parse expression after 'while'
48) End of line expected after' while' condition
49) 'while' without 'wend'
50) End of line expected after 'wend'
51) 'wend' without 'while'
52) Variable name expected after' for'
53) '=' expected after variable name
54) Could not parse expression after 'for'
55) 'to' expected
56) Could not parse expression after 'to'
57) Could not parse expression after 'step'
58) End of line expected
59) 'for' without 'next'
60) End of line expected after 'next'
61) 'Next' without 'for'
62) Could not parse expression after'if'
63) 'then' expected
64) Unexpected end of file while looking for 'endif'
65) Unexpected end of file while looking for 'else' or 'endif'
66) 'else' without ‘if'
67) 'end if' without 'if'
68) Label name expected after 'goto'
69) Unexpected end of line while looking for ')' in function call
70) ',' expected
71) Missing ')'
72) Unexpected end of line in expression
73) Unexpected end of file in expression
Last updated