Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Calculated AppleScript Question

Featured Replies

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

Try =

Let ( [

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

sec = GetAsNumber ( BioasysScriptProgressMonitor::OneSD ) ;

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

] ;

"do shell script " & Quote ( shell )

)

  • 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

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 )

)

  • 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

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.