• 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: set x to "0" = (do shell script "...") ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set x to "0" = (do shell script "...") ???


  • Subject: Re: set x to "0" = (do shell script "...") ???
  • From: Steve Mills <email@hidden>
  • Date: Mon, 24 Jul 2017 20:35:56 +0000 (GMT)

On Jul 24, 2017, at 02:51 PM, Jim Weisbin <email@hidden> wrote:

I was Googling around, looking into ways to use regex in AS, when I came across this page:

https://stackoverflow.com/questions/997828/is-there-something-akin-to-regex-in-applescript-and-if-not-whats-the-alternat

In a few places the code snippets there have the construct:

set x to "0" = (do shell script “…”) etc

I have no idea what that does, or why it compiles. What am I missing?

It's easy enough to deconstruct this syntax. First, see what the results of the "do shell script" are.

Then look at what the script is doing: x is being set to the result of the comparison of "0" to the shell script result. So if the result of the shell script is "0", then x will be set to true.

This is why I like using "is" instead of "=" when doing comparisons. It's a lot more readable for anyone coming from languages where "=" is an assignment operator.

Sent from iCloud's ridiculous UI, so, sorry about the formatting

 
 _______________________________________________
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

References: 
 >set x to "0" = (do shell script "...") ??? (From: Jim Weisbin <email@hidden>)

  • Prev by Date: set x to "0" = (do shell script "...") ???
  • Next by Date: Re: set x to "0" = (do shell script "...") ???
  • Previous by thread: set x to "0" = (do shell script "...") ???
  • Next by thread: Re: set x to "0" = (do shell script "...") ???
  • Index(es):
    • Date
    • Thread