(*
  EIP_DO_SET - write one digital output point of a remote EIP coupler.
  Returns the value written (xVal).

  iRemote = EIP_REMOTE1..EIP_REMOTE4 (1..4), iNum is a 0-based point number.

  Digital outputs occupy 200 points per coupler:
    coupler 1  M6000..M6199
    coupler 2  M6200..M6399
    coupler 3  M6400..M6599
    coupler 4  M6600..M6799
  Devices are addressed through the index register Z0, so the body computes
  the device from base + (coupler - 1) * step + point.

  Arguments are clamped with LIMITATION: iRemote to 1..4 and iNum to
  0..199, so a call with an out-of-range point reads/writes the nearest
  valid point instead of being skipped.
  The return type is set in the GX Works 2 POU properties.
*)
Z0 := 6000 + (LIMITATION(1, iRemote, 4) - 1) * 200 + LIMITATION(0, iNum, 199); (* M6000 + coupler offset *)
M0Z0 := xVal;
EIP_DO_SET := xVal; (* return the value written *)
