Monday, December 9, 2019

#1 2019-12-04 05:14:50 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 565

Unwanted popup from applet

Applescript:

set pathToFileWork to "HD:Users:USER:Desktop:File.rtf"
set pathToFolderBackups to "HD:Users:USER:Desktop:Folder:"

try -- trap Finder duplicate error
   tell application id "MACS" to set Dup to duplicate alias pathToFileWork to folder pathToFolderBackups
end try

When run from the Editor all is well: after the 1st run the error is suppressed.
However, when run as an applet an alert pops up after the 1st run, asking if I want to overwrite | stop | keep both.
This is what an application should do, but it seems it happens outside AppleScript, as the try block is ignored.
I'm thinking I should test for the presence of a duplicate, instead of using a try block.
Is there another solution?

(The actual script with this code keeps running after I dismiss the alert, but I just don't want to see it.)

Offline

 

#2 2019-12-04 08:13:15 am

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

Re: Unwanted popup from applet

I find the applet suppresses the error if it explicitly specifies duplicating without replacing (which I presume is the intention):

Applescript:

local pathToFileWork, pathToFolderBackups, Dup

set pathToFileWork to "HD:Users:USER:Desktop:File.rtf"
set pathToFolderBackups to "HD:Users:USER:Desktop:Folder:"

try -- trap Finder duplicate error
   tell application id "MACS" to set Dup to duplicate alias pathToFileWork to folder pathToFolderBackups without replacing
end try


NG

Offline

 

#3 2019-12-06 03:53:16 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 565

Re: Unwanted popup from applet

Nigel Garvey wrote:

(which I presume is the intention)

It is, yes.
Thanks for the heads up re dictionaries.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)