June 28, 201114 yr Hello, I am trying to write a calculated AppleScript. The AppleScript I am using is as follows: set theTime to 5 do shell script "osascript /Applications/BioasysSendMail.scpt " & theTime & " &> /dev/null &" If I run this as a native AppleScript in a PerformApplescript script step it runs just as expected. However I want to be able to calculate the number (in this example 5) in the first line from a time field on one of my layouts. I am essentially converting the time into total seconds. Here is the code I am using which converts the time into seconds: Let([ totTime = BioasysScriptProgressMonitor::OneSD; hourSec = Hour(totTime) * 3600; minSec = Minute(totTime) * 60; sec = Seconds(totTime); totSec = hourSec + minSec + sec]; totSec ) So, basically I want to replace 5 in the "set theTime to 5" with the totSec value I calculate in the Let Calculation. The syntax to accomplish this is eluding me. Does anybody know how to accomplish this. Sincerely, George
June 28, 201114 yr Try = Let ( [ template = "osascript /Applications/BioasysSendMail.scpt theTime > /dev/null &" ; sec = GetAsNumber ( BioasysScriptProgressMonitor::OneSD ) ; shell = Substitute ( template ; "theTime" ; sec ) ] ; "do shell script " & Quote ( shell ) )
June 28, 201114 yr Author Try = Let ( [ template = "osascript /Applications/BioasysSendMail.scpt theTime > /dev/null &" ; sec = GetAsNumber ( BioasysScriptProgressMonitor::OneSD ) ; shell = Substitute ( template ; "theTime" ; sec ) ] ; "do shell script " & Quote ( shell ) ) Hi Thanks for your reply. I ended up having to change the calculated AppleScript to: tell application "BioasysSendMail" to update(theTime, true) where theTime is the value in field: BioasysScriptProgressMonitor::FourSDMin Using your code as an example I got as far as: Let([ template = "tell application "BioasysSendMail" to update(time, true)"; sec = GetAsNumber(BioasysScriptProgressMonitor::FourSDMin); shell = Substitute ( template ; "time"; sec) ]; But from here I'm not sure what to do. Thanks again, Sincerely, George
June 28, 201114 yr template = "tell application "BioasysSendMail" to update(time, true)"; That's not going to work. You cannot have unescaped quotes within a text constant. Try = Let ([ template = "tell application \"BioasysSendMail\" to update(time, true)"; sec = GetAsNumber ( BioasysScriptProgressMonitor::FourSDMin ) ]; Substitute ( template ; "time" ; sec ) )
June 28, 201114 yr Author That's not going to work. You cannot have unescaped quotes within a text constant. Try = Let ([ template = "tell application \"BioasysSendMail\" to update(time, true)"; sec = GetAsNumber ( BioasysScriptProgressMonitor::FourSDMin ) ]; Substitute ( template ; "time" ; sec ) ) Hello, Excellent, Thank you, that worked beautifully. Sincerely, George
Create an account or sign in to comment