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.
Can "min" return the ordinal?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Can "min" return the ordinal?
Life is just a bowl of cherries.
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.
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
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
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode