Hi,
I'm just trying to work out how to compare a variant type.
The variant input parameter needs to be compared with a min and max limit. If it is below or above it, it then needs to make it equal the limit.
The parameter could be a REAL, INT, DINT, etc. So I want a block that can read the parameter and two limits as variants and then output the parameter.
I've managed to do the move block variant, but struggling to work out how to do the compare.
IF TypeOf(#Parameter) = TypeOf(#MaxLimit) AND TypeOf(#Parameter) = TypeOf(#MinLimit) THEN
#RT := MOVE_BLK_VARIANT(SRC := #Parameter, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInParameter);
#RT := MOVE_BLK_VARIANT(SRC := #MinLimit, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInMinLimit);
#RT := MOVE_BLK_VARIANT(SRC := #MaxLimit, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInMaxLimit);
#Type := 0;
ELSE
#Type := 1;
END_IF;
Any ideas?
Thanks
I'm just trying to work out how to compare a variant type.
The variant input parameter needs to be compared with a min and max limit. If it is below or above it, it then needs to make it equal the limit.
The parameter could be a REAL, INT, DINT, etc. So I want a block that can read the parameter and two limits as variants and then output the parameter.
I've managed to do the move block variant, but struggling to work out how to do the compare.
IF TypeOf(#Parameter) = TypeOf(#MaxLimit) AND TypeOf(#Parameter) = TypeOf(#MinLimit) THEN
#RT := MOVE_BLK_VARIANT(SRC := #Parameter, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInParameter);
#RT := MOVE_BLK_VARIANT(SRC := #MinLimit, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInMinLimit);
#RT := MOVE_BLK_VARIANT(SRC := #MaxLimit, COUNT := 1, SRC_INDEX := 0, DEST_INDEX := 0, DEST => #tempInMaxLimit);
#Type := 0;
ELSE
#Type := 1;
END_IF;
Any ideas?
Thanks