Re: sub-routines' error
Re: sub-routines' error
- Subject: Re: sub-routines' error
- From: Deivy Petrescu <email@hidden>
- Date: Wed, 10 May 2017 08:55:42 -0400
> On May 10, 2017, at 07:59 , Maik Waschfeld <email@hidden> wrote:
>
> Hi AS-users,
>
> I’m trying to get a little deeper into the sub-routine-thing.
> But I’m stuck at a strange error -1708, that I can reproduce with the following script.
>
> use AppleScript version "2.4" -- Yosemite (10.10) or later
> use scripting additions
>
> on run
> set the_List to {}
>
> activate
>
> set the_Files to (choose file with prompt "Please select a file to process:" with multiple selections allowed)
>
> repeat with f from 1 to (count of the_Files)
> set the_File to (the_Files's item f)
>
> my the_Name(the_File)
>
> set the_List's end to (the_Name)
> end repeat
>
> display dialog ("the_Files: " & the_Files & "\n\nthe_List: " & the_List)
>
> end run
>
> on the_Name(the_File)
> tell application "Finder"
> set the_Name to name of the_File
> end tell
> end the_Name
>
>
> When selecting more than one file, so that the sub-routine runs multiple times, I get this error:
> error „«script» doesn’t understand the message „the_Name“.“ number -1708 from «script»
>
> As far as I understand AppleScript, there’s basically nothing wrong with the script.
>
> If I replace the „my the_Name(the_File)“ line with
> tell application "Finder"
> set the_Name to name of the_File
> end tell
> no error comes up, even when I select quite a lot files.
>
> Any hints, how I get it to work, anyway?
>
>
> With kindest regards…
> …Maik Waschfeld
>
> (sent from my MBAir11)
Your handler is not returning anything.
Also you are calling the handler, which does not return anything, without any parameters.
this will work, in spite of the fact that I would write it differently
—————
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on run
set the_List to {}
activate
set the_Files to (choose file with prompt "Please select a file to process:" with multiple selections allowed)
repeat with f from 1 to (count of the_Files)
set the_File to (the_Files's item f)
set the_List's end to the_Name(the_File)
end repeat
display dialog ("the_Files: " & the_Files & return & " the_List: " & the_List)
end run
on the_Name(the_File)
tell application "Finder" to return name of the_File
end the_Name
---------------
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden