• 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: Takaaki Naganoya <email@hidden>
  • Date: Thu, 23 Feb 2006 16:17:30 +0900
  • Thread-topic: if conditionals

How about use condition list?

<script>

--Hit Pattern Condition List {updateImages, reflowText, remapFonts,
docPrefs, patternValue}
set condPatList to {{"yes", "yes", "yes", "yes", 1}, {"yes", "yes", "yes",
"no", 2}, {"yes", "no", "yes", "no", 3}}

--dummy data for test
set updateImages to "yes"
set reflowText to "yes"
set remapFonts to "no"
set docPrefs to "no"

set aRes to 0 --default value

--judge
repeat with i in condPatList
    set {cond1, cond2, cond3, cond4, condValue} to i
    if {cond1, cond2, cond3, cond4} = {updateImages, reflowText, remapFonts,
docPrefs} then
        set aRes to condValue
        exit repeat
    end if
end repeat
if aRes = 0 then return --no hit

--execute by condition value
if aRes = 1 then
    --something in case 1
    display dialog "pattern 1"
else if aRes = 2 then
    --something in case 2
    display dialog "pattern 2"
else if aRes = 3 then
    --something in case 3
    display dialog "pattern 3"
else
    --
end if

</scriipt>

--
Takaaki Naganoya
Piyomaru Software
http://www.appleco.jp/piyomarusoft/

On 06.2.23 3:08 PM, "Mark Butler" <email@hidden> wrote:

> Hello Everyone,
>
> 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?
>
> Mark
>
>
>  _______________________________________________
> 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
>


 _______________________________________________
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: Scripting Print Window settings without UI scripting?
  • Next by Date: Re: Finding a decent Applescript reference/tutorial?
  • Previous by thread: if conditionals
  • Next by thread: Re: if conditionals
  • Index(es):
    • Date
    • Thread