Max Value in a array
Edi Murway from United States  [11 posts]
4 year
I'm using Line profile to determine when an item crosses any part of the line.
The maximum value returned used as a threshold works well (I need it fast) or I would just script it.
I need to know the maximum value returned by Line_Profile_Values.
I have tried Sort with some effect but it's not clear how to use it.
Also is there new documentation on the new sort module, there are 2 new fields (record size and field offset)

Is there another way (other than scripting) to get a fast Max Value from an array?

Steven Gentner from United States  [1446 posts] 4 year

The two fields for the sort have to do with working in arrays that have multiple values. For example if you have an array of X and Y values the record size is 2 and the field offset would be 1 if you wanted to sort on X and 2 if you wanted to sort on Y. Since you can also have 3 or 4 or N numbers in an array that are associated like a record, that's the reason for those fields.

In your case, a record size and offset of both 1 will work. It is NOT the size of the array. The module knows the length/size of the array from accessing that within RR.

Alternatively, you can also find the max value by using a small VBScript that should execute quite quickly. Something like


line = GetArrayVariable("Line_Profile_Values")
max = 0
if isArray(line) then
  for i = 0 to ubound(line)
    if line(i) > max then max = line(i)
end if

write "The max is " & max


running from within a VBScript module.

Edi Murway from United States  [11 posts] 4 year
Got It, Thank you STeven
Edi Murway from United States  [11 posts] 4 year
Hi again,
Actually the array returned by the line profile module requires a record size of 3 and an offset of 1 to return the Max Value anywhere in the array. It's fast and works great.

An Ascending Sort will return the Min value in the array and Descending will return the Max value anywhere in the array.

The first element in the reordered array will be the result.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index