Skip to content

MaxIntValue ​

The MaxIntValue function returns the largest signed value in the integer data array aValues.

Please also see MinIntValue for a function that returns the smallest array value.

Declaration: Function MaxIntValue(const aValues : array of Integer) : Integer

This function is illustrated two (2) ways below.

pascal
procedure ScriptEvent (var Value : variant);
var
    arrAges : array[1..10] of integer;
    iCount, MaxCount : integer;

    arrRandom : array[1..10] of integer;
    RandCount : integer;

begin
  LogInfo('Counting up and writing ARRAY entries . . . ');
  iCount := 1;
 FOR iCount := 1 to 10 do
 begin
    arrAges[iCount] := iCount * 2;
    LogInfo('Counter number is - '+IntToStr(iCount));
    LogInfo('ARRAY number is   - '+IntToStr(arrAges[iCount]));
    LogInfo('');
 end;
  LogInfo('');
  LogInfo('MaxIntValue the array . . . . ');
  MaxCount := MaxIntValue(arrAges);             //The highest value number in the array
  LogInfo(IntToStr(MaxCount));
  LogInfo('');
  LogInfo('');

  LogInfo('Setting individual array values . . . . ');
  arrRandom[1] := 2;
  arrRandom[2] := 78;
  arrRandom[3] := -34;
  arrRandom[4] := 289;
  arrRandom[5] := 945;
  arrRandom[6] := 274;
  arrRandom[7] := 4587;
  arrRandom[8] := 47;
  arrRandom[9] := 2189;
  arrRandom[10] := -4588;
  LogInfo('MaxIntValue the array . . . . ');
  RandCount := MaxIntValue(arrRandom);             //The highest value number at position 7 in the array
  LogInfo(IntToStr(RandCount));
   LogInfo('');
  LogInfo('');

end;

The resulting log follows.

image-20240206-225730.png