- Posts: 12
- Thank you received: 0
Some problems in ST implementation.
- Sergey Romanov
- Offline
- New Member
Less
More
6 years 3 months ago #282
by Sergey Romanov
Some problems in ST implementation. was created by Sergey Romanov
I am sorry I'll mention Codesys again.
This is about passing array variable to function block without knowing number of elements
If I have this code
It will not work because axIN and axMyArray does not match. Although following code would work in Codesys.
Although FB variable and variable I path does not match in number of elements it is still a valid code until INPUT variable defined with more elements than variable referenced.
The same sample but wih REF_TO abd REF() does not work in logi.CAD which is a frustration. I do not see any other way to create function block that can accept arrays of different length.
This is about passing array variable to function block without knowing number of elements
If I have this code
Code:
PROGRAM
VAR
axMyArray: ARRAY[1..5] OF BOOL;
fbTest1: Test;
END_VAR
fbTest1(axIN := axMyArray);
END_PROGRAM
FUNCTION_BLOCK Test
VAR_INPUT
axIN: ARRAY[1..100] OF BOOL;
END_VAR
VAR
iCount: INT;
END_VAR
FOR iCount := 1 TO 100 DO
axIN[iCount] := TRUE;
END_FOR;
END_FUNCTION_BLOCK
It will not work because axIN and axMyArray does not match. Although following code would work in Codesys.
Code:
PROGRAM
VAR
axMyArray: ARRAY[1..5] OF BOOL;
fbTest1: Test;
END_VAR
fbTest1(axIN := ADR(axMyArray), iSize := SIZEOF(axMyArray));
END_PROGRAM
FUNCTION_BLOCK Test
VAR_INPUT
axIN: POINTER TO ARRAY[1..100] OF BOOL;
iSize: INT;
END_VAR
VAR
iCount: INT;
END_VAR
FOR iCount := 1 TO iSize DO
axIN^[iCount] := TRUE;
END_FOR;
END_FUNCTION_BLOCK
Although FB variable and variable I path does not match in number of elements it is still a valid code until INPUT variable defined with more elements than variable referenced.
The same sample but wih REF_TO abd REF() does not work in logi.CAD which is a frustration. I do not see any other way to create function block that can accept arrays of different length.
Please Anmelden or Create an account to join the conversation.
- Walter Zögernitz
- Visitor
6 years 1 month ago #306
by Walter Zögernitz
Replied by Walter Zögernitz on topic Some problems in ST implementation.
Please login to view the answers
Please Anmelden or Create an account to join the conversation.
- Sergey Romanov
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
6 years 1 month ago #307
by Sergey Romanov
Replied by Sergey Romanov on topic Some problems in ST implementation.
Please login to view the answers
Please Anmelden or Create an account to join the conversation.
- Walter Zögernitz
- Visitor
6 years 1 month ago #309
by Walter Zögernitz
Replied by Walter Zögernitz on topic Some problems in ST implementation.
Please login to view the answers
Please Anmelden or Create an account to join the conversation.