PAC Control Subroutine Chart Parameter

Is there a way to pass a Chart to a subroutine as a parameter? I didn’t see it in the list of types when setting up the parameters. I also thought about passing a pointer to a chart but Pointer variables aren’t in the list either, only pointer tables.

I have several charts that run specific processes. When the process is complete, it sets a variable (State) and the calling chart will set a handshake variable (Request). The process chart, on seeing the Request, will finish up some stuff then reset State and stop. I’ve created a subroutine that can do this and I pass it the State and Request variables (by ref) associated with the specific chart I’m stopping. However, I’d like to ensure that the chart itself has stopped before I continuing. I know I can do that in the calling chart but it would be nice if the subroutine can do it so the stop routine is in a compact single-call function.

Thanks!

Since you can use pointer tables, setup a single element pointer table and assign the chart to element 0 and pass this into your subroutine.

Example

In the calling chart, assign to the pointer table and call the subroutine:

//Assign chart to pointer table
ptChart[0] = &TestChart;
//Call subroutine
ChartRunning(ptChart, ChartStatus);

In the subroutine, assign the pointer table element to a chart pointer variable that you define in the subroutine and use as normal:

//Assign the pointer in the table to a pointer variable
pChart = ptChart[0];
//Do whatever operation is needed
ChartStatus = GetChartStatus(*pChart);
2 Likes