I’m trying to get maximum value of record in a particular field. For eg, if we have field name “StyleNo” and the records are 1,3,5,6,8,9,. In this the maximum value of record in StyleNo field is 9. I have tried with the following code but it is not working
tell application
activate
set sno to (maximum of record) in field “StyleNo”
end tell
how can i write script for this?
jacintha
Hi jacintha,
I don’t know, which application you want to use.
Maybe this app contains keywords like maximum or field,
but plain AppleScript has no idea about these .
To determine the maximum value in a comma separated string
you have to coerce the values of the string to a list and go through it
set R to "1,13,8,3,12,10"
set {TID, text item delimiters} to {text item delimiters, ","}
set valList to text items of R -- coerce the string to a list
set text item delimiters to TID
set maxValue to 0
repeat with i in valList
if i as integer > maxValue then set maxValue to contents of i as integer
end repeat
maxValue --> 13
The application which i’m using is “filemaker pro”. In apple script i have to write script to find the maximum value in field “StyleNo” which is in filemaker pro 8.
This should work… Assuming I understtod you correctly and you are trying to get the max style number from your field across ALL records.
tell application "FileMaker Pro"
tell database "your database name"
set SNOlist to field "StyleNo"
end tell
end tell
set maxSNO to 0
repeat with i in SNOlist
if i as integer > maxSNO then set maxSNO to i as integer
end repeat
Thank you so much. Your code helps me to proceed my work. For this Maximum styleNo i have to get the Maximum ElementNo.
I have database and fields like
StyleNo StyleName ElementNo ElementName
1 aaa 1 ab
2 bbb 0 ba
2 ccc 1
2 2
4 0
4 1
6 0
6 1
6 2
6 3
The maximum style no is 6, for this maximum style no, the maximum element no is 3. i have to script it. how can i do?
Hi,
do you have any idea about this.
This should work for you
tell application "FileMaker Pro"
tell database "your database name"
set SNOlist to field "StyleNo"
set maxSNO to 0
repeat with i in SNOlist
if i as integer > maxSNO then set maxSNO to i as integer
end repeat
show (every record whose cell "StyleNo" is maxSNO)
end tell
tell current layout
set ENlist to field "ElementNo"
end tell
set maxEN to 0
repeat with i in ENlist
if i as integer > maxEN then set maxEN to i as integer
end repeat
end tell