read

[ Function ]

Version 1.8

public read(): any;

Version 1.12

public read<T = ST>(): T;

Reads the value of the symbol.

read 1:

From version 1.10, symbol queries are executed directly against the component that makes the data available. Since a synchronous query of symbols from the server is not possible, please use the function readEx to query server symbols.

read 2:

Version 1.12: If the API is used in TypeScript code, the symbol type (ST: SymbolType) can be reported to the TypeScript compiler when a symbol is created. This then no longer has to be specified when using this function, although it can be overwritten.

read 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

-

-

-

Return value

Type

Description

Version 1.8

any

Version 1.12

T

Current value of the symbol. Can have any type.

read 4:

Available from 1.8

Sample - JavaScript

var sym = new TcHmi.Symbol('%i%myInternalSym%/i%');
var symVal = sym.read();

Sample 1 - TypeScript

let sym = new TcHmi.Symbol ('%i%myInternalSym%/i%');
let symVal = sym.read(); // TS does not know the variable type

Sample 2 - TypeScript

let sym = new TcHmi.Symbol<boolean>('%i%myInternalSym%/i%');
let thisIsABoolean = sym.read(); // TS knows this is a boolean

Example 3 - TypeScript

let sym = new TcHmi.Symbol('%i%myInternalSym%/i%');
let thisIsABoolean = sym.read<boolean>(); // Define as a Boolean