• 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: booleans...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: booleans...


  • Subject: Re: booleans...
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 20 Mar 2018 17:15:18 +1100

On 20 Mar 2018, at 4:02 pm, Jean-Christophe Helary
<email@hidden> wrote:
>
> What I want, as I wrote earlier, is a way to coerce any statement to boolean
> values

You can't coerce a statement to anything; you can only coerce objects.
AppleScript statements can return results, which may be booleans or may be
something else entirely.

> Either a statement returns a value and it is true, or it returns an error (or
> nil) and it is false. A la lisp. Is that possible?

It's possible to define APIs like that: the "exists" command is a fine example.
But an AppleScript statement never *returns* an error -- it *throws* an error.
It abandons whatever it's doing, mid-statement, and throws an error that, minus
a trap, will bring the whole script to a halt. That's how exception-based
languages work. So if you are going to have a statement that throws an error,
you have to wrap the evaluation of that statement in a try block.

If you want to delay evaluation, then use one of Stan's suggestions or wrap it
in a script object. Or use AppleScriptObjC APIs -- Objective-C eschews
exceptions, so failure is always represented by a boolean of nil.

But you're going to be eternally disappointed if you keep looking at squares
and thinking they'll be great circles once you learn to chip off the corners.


--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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

  • Follow-Ups:
    • Re: booleans...
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Re: booleans... (From: Stan Cleveland <email@hidden>)
 >Re: booleans... (From: Jean-Christophe Helary <email@hidden>)
 >Re: booleans... (From: Shane Stanley <email@hidden>)
 >Re: booleans... (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: booleans...
  • Next by Date: Re: booleans...
  • Previous by thread: Re: booleans...
  • Next by thread: Re: booleans...
  • Index(es):
    • Date
    • Thread