Acceso a variables en matrices, estructuras y bloques
Acceso a elementos de la matriz
Sintaxis:
<nombre de la variable de matriz> [<lista de índices de dimensiones separados por comas>]
<nombre de la variable de matriz> | Nombre de la variable de matriz Ejemplo: Para más información, ver: Asignar identificador |
<lista de índices de dimensiones separados por comas> | Un índice por dimensión, para que se identifique un elemento de la matriz. Ejemplo: El índice es válido desde el mínimo del índice hasta el máximo del índice. Ejemplo: |
Matriz unidimensional con 10 componentes.
//Declaration VAR aiCounter : ARRAY[0..9] OF INT; iLocalVariable : INT; END_VAR // Implementation iLocalVariable := aiCounter[2];
Matriz bidimensional con 2 veces 2 componentes
//Declaration VAR aiCardGame : ARRAY[1..2, 3..4] OF INT; iLocal_1 : INT; END_VAR //Implementation iLocal_1 := aiCardGame[1, 3];
Para más información, ver: ARRAY OF
Acceso a los componentes de la estructura
Sintaxis:
<nombre de la variable de estructura> . <nombre del componente>
<nombre de la variable de estructura> | Ejemplo: Para más información, ver: Asignar identificador |
<nombre del componente> | Ejemplo: |
//Declaration type TYPE S_POLYGONLINE : STRUCT aiStart : ARRAY[1..2] OF INT := [-99, -99]; aiPoint1 : ARRAY[1..2] OF INT; aiPoint2 : ARRAY[1..2] OF INT; aiPoint3 : ARRAY[1..2] OF INT; aiPoint4 : ARRAY[1..2] OF INT; aiEnd : ARRAY[1..2] OF INT := [99, 99]; END_STRUCT END_TYPE //Declaration structure variable VAR sPolygon : S_POLYGONLINE; iPoint : INT; END_VAR //Implementation iPoint := sPolygon.aiPoint1[1];
Para más información, ver: STRUCT
Acceso a variables en POU
Sintaxis:
<nombre de la POU> . <nombre de la variable>
<nombre de la POU> | Nombre de una instancia de bloque de funciones ( Ejemplo: Para más información, ver: Asignar identificador |
<nombre de la variable> | Variable de la POU Ejemplo: |
FUNCTION_BLOCK FB_Controller VAR_INPUT xStart : BOOL; END_VAR VAR_OUTPUT END_VAR VAR ControlDriveA : S_CONTROL; END_VAR IF xStart = TRUE THEN //Symbolic bit access ControlDriveA.bitEnableOperation := TRUE; END_IF PROGRAM PLC_PRG fbController : FB_Controller; END_VAR fbController(); fbController.xStart := TRUE;