Код:
FUNCTION GRAPH : REAL;
VAR_INPUT
x :REAL;
END_VAR
VAR
arX: ARRAY[0..49] OF REAL := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50];
arY: ARRAY[0..49] OF REAL := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50];
i: udint;
END_VAR
IF x < arX[0] THEN GRAPH := arY[0];
ELSIF x > arX[49] THEN GRAPH := arY[49];
ELSE
FOR i:=0 TO 48 DO
IF x >= arx[i] AND x <= arx[i+1] THEN
GRAPH := LINEAR(x, arx[i], arx[i+1], ary[i], ary[i+1]);
END_IF;
END_FOR;
END_IF;
end_function
FUNCTION LINEAR : REAL;
VAR_INPUT
rX, rX1, rX2, rY1, rY2 : REAL;
END_VAR
IF rX2 = rX1 THEN LINEAR := rY2;
ELSE LINEAR := (rX - rX1) * (rY2 - rY1) / (rX2 - rX1) + rY1;
END_IF;
end_function