Jump to content
Server Maintenance This Week. ×

Calculated AppleScript Question


This topic is 4687 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

Try =

Let ( [

template = "osascript /Applications/BioasysSendMail.scpt theTime > /dev/null &" ;

sec = GetAsNumber ( BioasysScriptProgressMonitor::OneSD ) ;

shell = Substitute ( template ; "theTime" ; sec ) 

] ;

"do shell script " & Quote ( shell )

)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 )

)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 4687 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.