
FUNCTION FC64 : byte

VAR_TEMP
    // variables temporaires
    i: INT;
    temps, memTemps: DINT;
END_VAR
FC64 := 17;
temps:=0;
FOR i:=1 TO 16 DO
    memTemps:= "Stock_DB".stockTimer[i];
    IF "Stock_DB".stock[i] AND memTemps > temps THEN
        temps:= memTemps;
        FC64 := INT_TO_BYTE(i);
    END_IF;
END_FOR;
        
END_FUNCTION
