get
[ Function ]
Version 1.8
export function get(
id: string | null | undefined
): TcHmi.Controls.System.baseTcHmiControl | undefined;
Version 1.12
Export function get<T extends TcHmi.Controls.System.baseTcHmiControl>(
identifier: string | null | undefined
): T | undefined;
Returns a control with a specific identifier.
Version 1.12
If the API is used in TypeScript code, the TypeScript compiler can be notified of the control type.
Notice | |
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 |
---|---|---|
id | Identifier of the desired control. |
Return value
Type | Description |
---|---|
The requested control object or undefined if no control with this identifier exists. |
Available from 1.8 |
Sample - JavaScript
var someControl = TcHmi.Controls.get('TcHmiButton');
if(someControl !== undefined) {
someControl.setText('found you');
}
Sample - TypeScript
var someControl = TcHmi.Controls.get<TcHmi.Controls.Beckhoff.TcHmiTextbox>('TcHmiButton');
if(someControl !== undefined) {
someControl.setText('found you'); // TS knows this has setText
}