find largest value

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

find largest value

Post by Ron Zellner » Thu Apr 15, 2010 3:54 am

Anyone know of a quick way to determine the largest value in a row or column in a table? (numerical data)
(Other than setting up repeats and comparing a series of pairs )

Thanks,
Ron

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: find largest value

Post by sturgis » Thu Apr 15, 2010 4:03 am

Well, for a row it would be pretty easy. Since tables are tab delimited, put the line in question into a variable, replace tab with comma in the variable so that its a number list, and use the max() function.

For column, I believe you do need a repeat, off the top of my head something like

Code: Select all

repeat for each line theLIne in field "tablefield"
put item 3 of theLIne & comma after tempVar -- build the number list
end repeat
delete the last char of tempVar -- cut the trailing comma
get max(tempVar) -- find the max
edit: Forgot, you need to set the itemdelimiter to tab for this to work. Add a line like
set the itemdelimiter to tab above the start of the repeat.

Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

Re: find largest value

Post by Ron Zellner » Thu Apr 15, 2010 4:16 am

That's embarrassing- I forgot about the Max() function :oops: -! Use it all the time in Excel, etc.
Guess it's time to stop for the night.

Post Reply