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



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