read

[ Function ]

Version 1.8

public static read(name: string, type: TcHmi.SymbolType): any;

Version 1.12

public static read<T = any>(name: string, type: TcHmi.SymbolType): T;

Reads the value of a symbol addressed by its name and symbol type.

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 readEx2 to query server symbols.

read 2:

Version 1.12: If the API is used in TypeScript code, the TypeScript compiler can be notified of the symbol value type.

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

name

string

Name of the symbol

type

TcHmi.SymbolType

Symbol type

Return value

Type

Description

Version 1.8

any

Version 1.12

T

Current value of the symbol, can be of any type.

read 4:

Available from 1.8

Sample - JavaScript

var symVal = TcHmi.Symbol.read('myInternalSym', TcHmi.SymbolType.Internal);

Sample 1 - TypeScript


var symVal = TcHmi.Symbol.read('myInternalSym', TcHmi.SymbolType.Internal); // TS does not know the variable type

Sample 2 - TypeScript


let thisIsABoolean = TcHmi.Symbol.read<boolean>('myInternalSym', TcHmi.SymbolType.Internal); // TS knows this is a boolean