• 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: Finder Tell Blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder Tell Blocks


  • Subject: Re: Finder Tell Blocks
  • From: Sander Tekelenburg <email@hidden>
  • Date: Tue, 5 Mar 2002 14:05:19 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 10:09 -0500 UTC, on 04-03-2002, David Groover wrote:

> Thus spake email@hidden:

[...]

>>tell app "Finder"
>> set theProcesses to name of every process
>>end tell
>>if theProcesses contains "MACS"
>> display dialog true
>>end if

[...]

> When you wrote "display dialog true", Then I have some confusion.

Yes, I expected that to create some confusion ;) Sorry about that. But you
guessed right at what it means.

In AppleScript you can ask if a condition is true or false. In the above
situation, I felt this notation:

if theProcesses contains "MACS"
display dialog true
end if

would expain the original one-liner. But it is not the best explanation of
how to work with true/false conditions.

To find out if a condition is true or false, you simply state th condition.
AppleScript will return whether it is true or false. So this:

theProcesses contains "MACS"

will result either true, or false. (Make sure you have your "Results" window
open!)

If you want to work with the result, you can write:

set theTruth to theProcesses contains "MACS"

The variable theTruth will be set to either true or false. So now you have
the truth about a condition caught in a variable, so you can refer to it
later in your script. (Note that this variable only contains the truth
itself. It doesn't know *what* is true/false.)

So now we can write:

tell application "Finder"
set theProcesses to name of every process
end tell
set theTruth to theProcesses contains "MACS"
display dialog theTruth


The reason I wrote that differently at first is that I remember how I
personally found this confusing when I started out with scripting. Using "if,
then" was, although more lengthy, far more comprehensible to me.

Btw, Script Editor can do syntax colouring, but the default settings aren't
very useful. If you haven't done so already, go to "AppleScript
Formatting..." under the Edit menu, and set different colours/fonts for every
item you find. That will help recognize that something like true/false is a
keyword.

[...]

> And what about "display dialog true"? After reading that again I think
> you are just putting a dialog box on the screen that a true condition has
> been met

Exactly.


Does this help? You seemed to also have a more general question, but I didn't
understand it ;) So if this did not answer it, just phrase the question
differently and ask again. Or maybe someone else will jump in.


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPITCgusywKfXgqKdEQK46gCgpJEXQ/8Bl1YNBifcxQAwAHGW540AoPZd
zSouo+lNBbkQjQJlnKXboZ1Q
=7DQV
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
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: Finder Tell Blocks (From: David Groover <email@hidden>)

  • Prev by Date: NewbieQ: How to loop properly?
  • Next by Date: Opening SD's EnclosingFolder
  • Previous by thread: Re: Finder Tell Blocks
  • Next by thread: Re: Finder Tell Blocks
  • Index(es):
    • Date
    • Thread