9.2 Scripts 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:
Do not use too much script loops, if the script loops that execute too many times; it might influence the efficiency of HMI.
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.
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.
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.
Grammar Checking
Operating procedures
System does not prompt grammar error if grammar is correct, or system will list all errors;
Check error information, and modify errors;
Error information
Identifier *** contains invalid characters
Attempt to redeclare sub ***
Attempt to redeclare function ***
Attempt to use reserved word *** as identifier
Attempt to use type *** as identifier
Unexpected ')' while parsing arguments for function ***
Could not parse expression (one of the arguments of function ***)
Could not parse arguments of ***
Too many arguments for function ***
Not enough arguments for function ***
'(' expected after sub name ***
Unexpected '(' while parsing arguments for sub ***
Could not parse expression (one of the arguments of sub ***)
Could not parse arguments of ***
Too many arguments for sub/function ***
Not enough arguments for sub/function ***
Could not parse expression
'(' expected after function name ***
Unexpected use of sub *** as a part of expression
Illegal statements preceding subs/functions declaration
Unexpected end of file while looking for 'endsub'
End of line expected after 'else'.
End of line expected after 'endif'.
End of line expected after 'next'.
End of line expected after 'wend'.
'while', 'until' or end of line expected afte r'do'.
Could not parse expression after 'while'
Could not parse expression after 'until'
'do' without 'loop'
Sub *** contains invalid character'@'
Sub *** already declared
Function *** already declared
Sub name expected after 'sub'
Function name expected afte r'function'
Variable name expected
Argument *** contains invalid character '@'
'integer', 'floating' or 'string' expected
''',' or ')' expected
'endsub' without 'sub'
'end function' without 'function'
End of line expected after 'beep'
'dim' unexpected here
Variable name expected after 'dim'
'as' expected after variable name
'integer' 'floating' or 'string' expected after 'as'
',' or end of line expected after type in dim statement
Could not parse expression after 'while'
End of line expected after' while' condition
'while' without 'wend'
End of line expected after 'wend'
'wend' without 'while'
Variable name expected after' for'
'=' expected after variable name
Could not parse expression after 'for'
'to' expected
Could not parse expression after 'to'
Could not parse expression after 'step'
End of line expected
'for' without 'next'
End of line expected after 'next'
'Next' without 'for'
Could not parse expression after'if'
'then' expected
Unexpected end of file while looking for 'endif'
Unexpected end of file while looking for 'else' or 'endif'
'else' without ‘if'
'end if' without 'if'
Label name expected after 'goto'
Unexpected end of line while looking for ')' in function call
',' expected
Missing ')'
Unexpected end of line in expression
Unexpected end of file in expression
Last updated
Was this helpful?