Array of Program

szotyi
2024-08-28
2024-09-03
  • szotyi - 2024-08-28

    Hi!

    What is the proper and the easiest way to call programs through looping of array of programs, or pointer of program?
    instead of calling the programs one by one:
    prog1(inputX: 11);
    prog2(inputY: 12);
    prog3(inputZ: 13);

    similar like:
    VAR
    programsToCall : ARRAY [1..3] OF PROGRAM;
    END_VAR
    programsToCall[1] := prog1(inputX: 11);
    programsToCall[2] := prog2(inputY: 12);
    programsToCall[3] := prog3(inputZ: 13);

    FOR i := 1 TO 3 DO
    programsToCall[i] ();
    END_FOR

    Thanks.

     

    Related

    Talk.ru: 1
    Talk.ru: 2
    Talk.ru: 3


    Last edit: szotyi 2024-08-28
  • TimvH

    TimvH - 2024-09-03

    You cannot create an array of Programs. Create a Function Block for this purpose instead of a program.
    You can create an array of FB instances and call each instance in a loop.

     

Log in to post a comment.