Friday, November 16, 2018

#1 2018-09-12 03:57:35 am

ldicroce
Member
Registered: 2017-11-25
Posts: 70

Run script on the fly

why is this not working?

Applescript:

global myScriptText
set myScriptText to "beep" & return & "beep"

script HelloWorld
   display notification "Hello World!"
   myScriptText -- I would expect here the computer to make a beep sound!
end script
tell HelloWorld to run

I basically what to "create" a script into a text string and then run it ...
is that possible?

Thanks !

Offline

 

#2 2018-09-12 04:10:33 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4720

Re: Run script on the fly

Hi.

Since your script is text, you need to use the 'run script' command:

Applescript:

set myScriptText to "beep" & return & "beep"

run script myScriptText

Or less efficiently, but useful to some:

Applescript:

set myScriptText to "beep" & return & "beep"

do shell script ("osascript -e " & quoted form of myScriptText)


NG

Offline

 

#3 2018-09-12 04:37:33 am

ldicroce
Member
Registered: 2017-11-25
Posts: 70

Re: Run script on the fly

Thanks Nigel !!!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)