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

Re: if conditionals


  • Subject: Re: if conditionals
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 27 Feb 2006 13:06:37 -0800

On Feb 22, 2006, at 10:08 PM, Mark Butler wrote:

If I have 4 variables with 3 possible values each...

	set updateImages to  -- could be {yes, no, ask}
	set reflowText to  -- could be {yes, no, ask}
	set remapFonts to  -- could be {yes, no, ask}
	set docPrefs to  -- could be {yes, no, ask}

What is the easiest, or is there an easy way to split this into if statements?

I started trying to write this out... the long way it becomes alot of code.. Is that the only way?

No, but an appropriate solution will depend on what you need to do. Do all 81 possible permutations result in a unique action? If so, then then you're kind of stuck for it. However, if the four actions are all independent, then you really only need four "if" statements.


[Proceeding assuming they are independent, so this may be completely irrelevant...]

A good objection to raise is that each step may take a while, and if some of the variables are "ask", then you'd like to get all the asking out of the way immediately, so the user won't have to keep checking in every few minutes to see if it's asking another question. There's a fairly simple solution to this, however:

if updateImages is ask then
set b to button returned of (display dialog "Update the images?" buttons {"No", "Cancel", "Yes")
if b is "Yes"
set updateImages to yes
else
set updateImages to no
end if
end if
(similarly for reflowText, etc.)


	if updateImages is yes then
		-- your code here
	end


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >if conditionals (From: Mark Butler <email@hidden>)

  • Prev by Date: Re: Three InDesign scripting questions
  • Next by Date: Creating MacBinary files: command line or AScript tools?
  • Previous by thread: Re: if conditionals
  • Next by thread: Scripting Print Window settings without UI scripting?
  • Index(es):
    • Date
    • Thread