Monday, November 20, 2017

#1 2017-11-07 02:29:03 pm

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 521
Website

Tell handler - direct and indirect call

Strange. In previous versions of Mac Os I was able to run:

Applescript:


set App to "Script Editor"
tell application App
tell document 1
set pt to path
end
end

.. It doesn't work anymore. Whereas:

Applescript:

tell application "Script Editor"
tell document 1
set pt to path
end
end

...works of course.  Why the same script fails in case 1 ? roll roll roll
A string is a string be it a variable or declared explicitly.

(Sorry for the formatting, was written on my phone)

Offline

 

#2 2017-11-07 03:47:33 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

Re: Tell handler - direct and indirect call

Joy wrote:

Strange. In previous versions of Mac Os I was able to run:



The previous version of Mac OS was run by luck not by solid code wink

To make sure all the code is compiled into the right AppleEvents and to make sure the right dictionary is used while doing that you should use "using terms from".

Applescript:

set appName to "Script Editor"

using terms from application "Script Editor"
   tell application appName
       tell document 1
           set pt to path
       end tell
   end tell
end using terms from

The example code above should also be used in previous version of Mac OS.

Last edited by DJ Bazzie Wazzie (2017-11-07 03:48:11 pm)

Offline

 

#3 2017-11-07 06:07:58 pm

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 521
Website

Re: Tell handler - direct and indirect call

I see!
At some point Apple decided to change Applescript Editor with a generic substitution which isn't correct. AS Editor would fit better as it's shorter and not generic.
Maybe it's just an aesthetic reason to use a variable instead to use a direct call lol
Backward compatibility seems no more that easy this days.

I'm not sure if the Applescript Editor was better... In its newer versions - (yose and cap) the compile command causes the document to lose the insertion point and jumps for 2 seconds around like a crazy horse, let's say from line 100 to line 80 or so. Wasn't the case in older versions. This happens especially by very long scripts

Maybe this is the time to trash the Script Editor for good.
I'm also very tired of the caveman debugging: Script Debugger or Swift looks less outdated as sad this conclusion is about the vanilla Applescript editor that made us very happy

Offline

 

#4 2017-11-07 10:13:35 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

Re: Tell handler - direct and indirect call

Joy wrote:

At some point Apple decided to change Applescript Editor with a generic substitution which isn't correct.



For backward compatibility Script Editor responds to old app names just fine. No reason to use fancy code there.

Joy wrote:

AS Editor would fit better as it's shorter and not generic.



AppleScript lies on top of OSA – which is generic – and AppleScript is no more than a dialect (in theory). So getting rid of AppleScript in its name is fine because you can write with Script Editor OSA scripts using either JavaScript or AppleScript syntax. Getting rid of AS or AppleScript in the name is just common sense.

Joy wrote:

I'm not sure if the Applescript Editor was better... In its newer versions - (yose and cap) the compile command causes the document to lose the insertion point and jumps for 2 seconds around like a crazy horse, let's say from line 100 to line 80 or so. Wasn't the case in older versions. This happens especially by very long scripts



AppleScript becomes more strong with each version, from my experience that's a good thing. An scripting language that is more consistent than randomly choose whatever it likes when on a crossroad is not the way to go. On MS we call them funny quirks but in reality it just allows bad written code that is doomed to fail in some situations.

Joy wrote:

Maybe this is the time to trash the Script Editor for good.
I'm also very tired of the caveman debugging: Script Debugger or Swift looks less outdated as sad this conclusion is about the vanilla Applescript editor that made us very happy



Keep in mind that SD doesn't make you a better coder on any level.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)