Skip to main content

Some problems in ST implementation.

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
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
  • 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.

More
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
  • 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.

Powered by Kunena Forum