Re: "exists" not working
Re: "exists" not working
- Subject: Re: "exists" not working
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 03 Apr 2002 08:44:43 -0800
On 4/3/02 8:00 AM, "Tracy Vanderwerf" <email@hidden>
wrote:
>
I have had no success in ever getting a question of mine answered on
>
this list, but will try again. Perhaps my questions are too elementary,
>
but I really am at a loss here and still a novice. Is there a "newbie"
>
list ?
>
I am running AS 9.0.4.
You must mean OS 9.0.4, which has AS 1.4.3 installed unless you've upgraded
the AppleScript extension separately.
(You should upgrade to OS 9.1 or, better, 9.2.1 - with AS 1.6 but _not_ to
OS 9.2.2. (AS 1.7 there has lots of bugs) unless you also want to upgrade AS
to the developer beta 1.8.2b3 which is very good.)
>
The code in question works outside of the main script and in Script
>
Debugger, but not within the script itself, which has a run handler with
>
parameters. The script just stops after the display dialog. The file
>
does exist and my variable is set to true if I run this outside of the
>
main script. What am I doing wrong?
Have you tried it in the 'main script' not using parameters but just setting
the values to see if the problem is with the parameter list technique or
with something else?
Assuming you have a proper string filepath, what do you expect to happen
next? in the snippet below, you are simply setting a variable, stuffed_file,
to true or false. what's supposed to happen with this value?
OK: this is what I think is happening. The Finder doesn't really like
'alias' although it can usually cope. It likes 'file'. But if there there
is indeed no such file, then 'alias my_expandpath' cannot resolve: it
errors, in a normal context (outside a Finder tell block), and the script
can't proceed. You get an error message and that's the end of your script.
However, in a Finder tell block, instead of sending up an error message "The
file [whatever it is] cannot be found", it will just quietly do nothing.
It's one of those things the Finder accommodates to be "kind". That's
probably what's happening here.
I would suggest avoiding the Finder, and its 'exists' property, altogether.
set my_expandpath to (filepath & ".sit")
try
get alias my_expandpath
set stuffed_file to true
on error
set stuffed_file to false
end if
>
>
on run{parameter list}
>
process_it(parameters)
>
>
other stuff
>
end run
>
>
on process_it(parameters)
>
>
set some variables
>
>
if (ADTYPE = "COU" or ADTYPE = "MIS" or ADTYPE = "WTM") then
>
set my_expandpath to (filepath & ".sit")
>
display dialog "my_expandpath = " & my_expandpath
>
tell application "Finder"
>
set stuffed_file to (exists (alias my_expandpath))
>
end tell
>
end if
>
>
>
end process_it
>
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.