Some problems in ST implementation.

More
1 year 2 months ago #282 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
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.
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 Log in or Create an account to join the conversation.

  • Walter Zögernitz
  • Visitor
  • Visitor
1 year 3 weeks ago #306 by Walter Zögernitz
Replied by Walter Zögernitz on topic Some problems in ST implementation.
Hello Sergey,

After detailed clarification with my collegues I'm afraid to tell you that there is still no possibility in logi.CAD 3 for array-inputs of an undefined size.

kind regards
Walter

Please Log in or Create an account to join the conversation.

More
1 year 3 weeks ago #307 by Sergey Romanov
Any hope that there ever will be that?

Please Log in or Create an account to join the conversation.

  • Walter Zögernitz
  • Visitor
  • Visitor
1 year 3 weeks ago #309 by Walter Zögernitz
Replied by Walter Zögernitz on topic Some problems in ST implementation.
Yes there is a hope. But this topic is not scheduled by now.

Please Log in or Create an account to join the conversation.

LOGI.CALS AUSTRIA

Address

Europaplatz 7/1,
3100 St. Pölten

LOGI.CALS GERMANY

Address

Postfach 1306,
40738 Langenfeld
© 1987 - 2019 logi.cals GmbH