hi ,
i would like to write a sub-program with multible outputs values,
when i compile my straton program hi have an error, Variable, constant expression or function call expected
hi ,
i would like to write a sub-program with multible outputs values,
when i compile my straton program hi have an error, Variable, constant expression or function call expected
Hi,
If you have this error, I think this is because you are trying to do it in an ST program.
If you want to recover multiple outputs on a Sub-Program, you have to use the same syntax as if it was an UDFB, even if a sub-program has no instance name.
The best is with an example.
Let's say you have a sub-program with this structure:
MySP:
IN_1 : IN
IN_2 : IN
OUT_1 : OUT
OUT_2 : OUT
Then in your ST program you must do something like that
MySP ( Input_1, Input_2 );
Output_1 := MySP.OUT_1;
Output_2 := MySP.OUT_2;
This should work
yes it is an ST sub program, you mean i need to define it as UDFB?
Ah no, you just have to use the same syntax.
I mean, normally, with a Sub-Program with only one output you can do something like:
Output_1 := MySP ( Input_1, Input_2 );
But with several outputs you can't.
So you have to do "like if it was an UDFB".
For example, with a counter:
Inst_CTU(...);
CtuIsFull := Inst_CTU.Q;
CtuValue := Inst_CTU.CV;
So for a sub-program, with, for example, two outputs called 'OUT_1' and 'OUT_2' (inside of the Sub-Program), you have to do something like:
MySP ( Input_1, Input_2 );
Output_1 := MySP.OUT_1;
Output_2 := MySP.OUT_2;
But you can keep it as a sub-program
(just take care about not calling many times the sub-program at different places, because when recovering the outputs values, as it is not instanciated, there can be some bad values)