Page 1 of 1

Can "min" return the ordinal?

Posted: Mon Mar 17, 2008 4:28 am
by bjb007
I have code like this...

put min(field lblFirst,field lblSecond,field lblThird) into varMin

but I want to know which field holds the minimum value
so I use...

if field lblFirst = varMin then
put 1 into varMin1
end if

etc.

Can the min function return the ordinal (i.e. 1,2,or3)?

I would also like to know if two fields contain the same
number.

Posted: Tue Mar 25, 2008 1:01 am
by Mark
Hi,

This script puts the number of the field with the minimum value into the message box. The script is a bit silly, because it creates two arrays in a repeat loop, but it works.

Code: Select all

on mouseUp
  repeat with x = 1 to 3
    put fld x into myVar[x]
    put x into myVar2[fld x]
  end repeat
  put myVar2[min(myVar)]
end mouseUp
Instead of "put x into myVar2[fld x]", you could also use "put the short name of fld x into myVar2[fld x]" and you could use an if statement to check for a custom property, to make sure that only the values of relevant fields are included.

Best,

Mark