• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "exists" not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "exists" not working


  • Subject: Re: "exists" not working
  • From: "Tracy Vanderwerf" <email@hidden>
  • Date: Wed, 03 Apr 2002 12:11:25 -0500
  • Organization: White Directory Publishers

Thank you to Paul Berkowitz and Deivy Petrescu for their responses.
Paul, thank you for the explanations (which helped me to understand my problem)
and suggestions. Yes, I am running AS 1.4.3.
I will consider the upgrade.
This is what I ended up doing:


if (ADTYPE = "COU" or ADTYPE = "MIS" or ADTYPE = "WTM") then
set my_expandpath to (filepath & ".sit")
display dialog "my_expandpath = " & my_expandpath
try
my_expandpath as alias
on error
set stuffed_file to false
end try
end if

Paul Berkowitz wrote:

> 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

[demime 0.98b removed an attachment of type text/x-vcard which had a name of tvanderwerf.vcf]
_______________________________________________
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.

References: 
 >Re: "exists" not working (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Reading large texts
  • Next by Date: Re: Coordinating lists
  • Previous by thread: Re: "exists" not working
  • Next by thread: Re: Resource fork interferes with text parsing
  • Index(es):
    • Date
    • Thread