Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if conditionals



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:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

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



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.