constructor

[ Function ]

public constructor(expression: string);

Creates a symbol instance.

constructor 1:

Instances created with new must be destroyed by calling the destroy function if they are no longer needed.

constructor 2:

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.

constructor 3:

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

string

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;
});
constructor 4:

Available from 1.8