In the ComfileHMI, a variable refers to a named location in the ComfileHMI hardware's memory.
If a variable is used without first being declared, it will be implicitly declared and available for use immediately.
A list of variables in use can be obtained from the ComfileHMI Editor's main menu: Project→View Addresses and Variables in Use.
String variables were added in a subsequent version of the ComfileHMI Editor software. They are declared and used with $
prefix. For example $a="hello"
.
Internal memory is a specific memory region in the ComfileHMI hardware. It is volatile, so it will be erased when the ComfileHMI hardware is powered off.
There are 1024 memory locations (indexed 0~1023) that can be written and read to. They can store 64-bit integers and double-precision floating point values.
set_mem(index, value)
: Writes value
to internal memory at index
.mem(index)
: Reads the value current stored in internal memory at index
.
Multiple values can be stored adjacently in internal memory by passing multiple value arguments to the set_mem
function.
set_mem(index, value1, value2, …, valueN)
See the internal memory functions.
Conditional expressions provide the ability to compare variables.
<
, <=
, ==
, >=
, >
, !=
operators are supported. They are identical to the comparison operators used in the C programming language.
&&
and ||
are boolean AND and boolean OR operators respectively.
(Example)
MotorStatus > 1
Heater1 == 0
⇐ true
if Heater1
is equal to 0
Heater1 != 0
⇐ true
if Heater1
does not equal 0
+
, -
, *
, /
, and %
operators are supported for performing math on variables. They are identical to the arithmetic operators used in the C programming language.
(Example)
MotorStatus + 1
>>
, <<
, |
, and &
operators are supported for bitwise operations. They are identical to the bitwise operators used in the C programming language.
(Example)
(bits >> 2) & 1
The Display and Location options provide the ability to specify how and where to display the widget. The default for the widget to always display.
Checking the based on condition option will provide the ability to show the widget based on a given condition. When the condition is met the widget is shown, otherwise it is hidden.
In the example below, the widget will be displayed when the motor status is 0. If other widgets or events in the ComfileHMI project cause the motor status to become 0, the widget will appear on the screen. Otherwise it will remain hidden.
The following video illustrates.