Reference Structured Text Question

Hello,

I have a programming question.
Let’s say I have a function block instance where, among the variables, I have a structured variable declared as VAR_IN_OUT.

Example:
fbMotor(

motorParameters := myMotorParameters;

)

However, first I would like to set the reference of myMotorParameters to two different structured variables based on a Boolean condition.

Example:

IF cond THEN
myMotorParameters := myMotorParameters1;
ELSE
myMotorParameters := myMotorParameters2;
END_IF;

If I try to declare myMotorParameters as a reference, the CPU goes into a page fault…
So I wanted to ask what is the best way to handle this case?
I’m not sure if I’ve explained myself clearly.
The idea is that, based on the condition, the FB reads/writes one structure rather than the other.

Thank you.

the correct syntax to provide the address of what you are referencing to the access command.

myMotorParameters ACCESS ADR(myMotorParameters1);