 F273_DMIN
F273_DMINMinimum value search in 32-bit data table
The function searches for the minimum value and its position in a 32-bit data table.

Input
Beginning of data table
End of data table
Output
minimum value
position of minimum value
Input s1_Start specifies the starting area of the data table, and s2_End specifies the end. The minimum value is returned at output Min and its position at output Pos.
The position Pos is relative to the position at the beginning of the data table to the first occurrence of the minimum value.
if the area specified using the index modifier exceeds the limit.
if the address of the variable at input s1_Start > s2_End
if s1_Start and s2_End belong to different data areas.
if the area specified using the index modifier exceeds the limit.
if the address of the variable at input s1_Start > s2_End
if s1_Start and s2_End belong to different data areas.

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		start: BOOL:=FALSE;
			(*activates the function*)
		data_array: ARRAY [0..4] OF DINT:=[4,7,-32,13,5];
		output_max: DINT:=0;
			(*the maximum value of 
data_array; here: -32*)
		output_pos: INT:=0;
			(*the position of the
maximum value; here: 2*)
	END_VARWhen the variable start is set to TRUE, the function is carried out.
It searches for the minimum value and its position in the data_field. The result is here: minimum_value = -333333 and position = 3.
BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_VARIN,,output,6,1,8,3,);
B(B_VARIN,,data field[0],6,2,8,4,);
B(B_VARIN,,data field[4],6,3,8,5,);
B(B_F,F273_DMIN,,8,0,17,5,,?DEN?D@'s1'?Ds2?AENO?Cmin?Cpos);
B(B_VAROUT,,minimum,17,2,19,4,);
B(B_VAROUT,,position,17,3,19,5,);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY
IF start then
    F273_DMIN( s1_Start:= data_field[0],
         s2_End:= data_field[4],
         Min=> minimum_value,
         Pos=> position);
END_IF;