• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get length of audio/video files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get length of audio/video files


  • Subject: Re: Get length of audio/video files
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 29 Oct 2011 12:39:09 +1100


On 29/10/2011, at 11:24 AM, Christopher Stone wrote:

All math is magic.  :)

Nah, this is math magic:

script evaluateFunction
set {theFunction, theValue} to current application's NSApp's passedValue() as list
set theValue to current application's NSExpression's expressionForConstantValue_(theValue)
set theExpression to current application's NSExpression's expressionForFunction_arguments_(theFunction, {theValue})
return theExpression's expressionValueWithObject_context_(missing value, missing value)
end script

-- return the sum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"sum:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

-- return the average of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"average:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

-- return the minimum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"min:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

-- return the maximum of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"max:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

-- return the median of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"median:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

-- return the standard deviation of a list of numbers
tell application "ASObjC Runner" to set theResult to run the script {evaluateFunction} passing {"stddev:", {1, 2, 3, 4, 5, 6, 7, 8, 9}} with result returned

:-)

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >RE: Re: (no subject)That (From: email@hidden)
 >Re: (no subject)Thatinteract with alerts (From: Dana Hill <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: email@hidden)
 >Get length of audio/video files (From: Bob Majors <email@hidden>)
 >Re: Get length of audio/video files (From: Christopher Stone <email@hidden>)
 >Re: Get length of audio/video files (From: Shane Stanley <email@hidden>)
 >Re: Get length of audio/video files (From: Christopher Stone <email@hidden>)
 >Re: Get length of audio/video files (From: Shane Stanley <email@hidden>)
 >Re: Get length of audio/video files (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: launchd user agent applescript do shell script error
  • Next by Date: Re: launchd user agent applescript do shell script error
  • Previous by thread: Re: Get length of audio/video files
  • Next by thread: Re: Get length of audio/video files
  • Index(es):
    • Date
    • Thread