constructor
[ Function ]
public constructor(expression: string);
Creates a symbol instance.
Instances created with new must be destroyed by calling the destroy function if they are no longer needed. |
Version 1.12: If the API is used in TypeScript code, the type of the symbol value that is written can be reported to the TypeScript compiler when a symbol is created. This then no longer has to be specified when using the read function, for example. |
This is a merely an auxiliary programming feature. The browser does not recognize this "type annotation". No check or conversion takes place at runtime. |
Parameter
Name | Type | Description |
---|---|---|
expression | Symbol expression |
Sample - JavaScript
var symbol = new TcHmi.Symbol('%i%myInternalSym%/i%');
symbol.readEx(function(data) {
// Do something with data.value…
symbol.destroy();
symbol = null;
return;
});
Sample 1 - TypeScript
var symbol: null | TcHmi.Symbol = new TcHmi.Symbol('%i%myInternalSym%/i%');
symbol.readEx(function(data) {
// Do something with data.value…
symbol?.destroy();
symbol = null;
return;
});
Sample 2 - TypeScript
var symbol: null | TcHmi.Symbol<boolean> = new TcHmi.Symbol<boolean>('%i%myInternalSym%/i%');
symbol.readEx(function(data) {
let thisIsABoolean = data.value; // TS knows this is a boolean
// Do something…
symbol?.destroy();
symbol = null;
return;
});
Available from 1.8 |