Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

MUX

Multiplexer — selects one of several inputs by index.

IEC 61131-3

Section 2.5.1.5.5

Support

Not yet supported

Signatures

#

Input (K)

Input (IN0)

Input (IN1, …)

Return Type

Support

1

INT

ANY

ANY

ANY

Not yet supported

Description

MUX(K, IN0, IN1, ...) returns the input selected by the zero-based index K. The number of inputs is variable, and all inputs must be the same type.

  • If K = 0, returns IN0

  • If K = 1, returns IN1

  • And so on

The behavior is undefined if K is negative or greater than or equal to the number of inputs.

This function is polymorphic: it works with any data type for the selected inputs.

Example

result := MUX(0, 10, 20, 30);    (* result = 10 *)
result := MUX(2, 10, 20, 30);    (* result = 30 *)

See Also

  • SEL — binary selection (two inputs)

  • LIMIT — clamp to range