# LGF_SearchMinMax_UDInt (FC / V3.0.1)

Author: Siemens Digital Industries

## Short description

This function searches, in an array of the data type UDInt, for the maximum and minimum value and the respective index in the array.

### Block Interface

| LGF_SearchMinMax_UDInt (FC) |
--- | --- | ---
|  |  |  |  | Ret_Val |  |  | Void
|  |  |  |  | minValue |  |  | UDInt
|  |  |  |  | minValueIndex |  |  | DInt
|  |  |  |  | maxValue |  |  | UDInt
|  |  |  |  | maxValueIndex |  |  | DInt
Array[*] of UDInt |  |  | values |  |  | Array[*] of UDInt

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Void | Void - Function has no return value
minValue | UDInt | Minimum value found in the array
minValueIndex | DInt | Index of the minimum found value in the array. The start index of the array plus `minValueIndex` results in the array index of the smallest value. The index starts with 0.
maxValue | UDInt | Maximum value found in the array
maxValueIndex | DInt | Index of the maximum found value in the array. The start index of the array plus `maxValueIndex` results in the array index of the smallest value. The index starts with 0.

### In/Out parameter

Identifier | Data type | Description
--- | --- | ---
values | Array[*] of UDInt | Array in whose fields the maximum and minimum are searched

## Functional description

An array of any size is connected via the `values` input. The elements are then compared in turn. The smallest and largest values, as well as their corresponding index are output to the array.

Note
  If there are several identical min. or max. values, the index of the first min. or max. value is output.

## Change log

Version & Date | Change description
--- | ---
| 01.00.00 | Simatic Systems Support
| 11.11.2019 | First release copied from "LGF_SearchMinMax" and reworked to array[*]
| 03.00.00 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 03.00.01 | Simatic Systems Support
| 09.02.2021 | Insert documentation