seems to meny If

Ken Ray kray at sonsothunder.com
Thu Nov 24 22:00:01 EST 2005


On 11/24/05 8:52 PM, "liamlambert" <liamlambert at mac.com> wrote:

> 
> how do I write this in a switch statement or is there a better way
> to write it
> 
> if it contains JK then send mouseUp to button "NextTrack"
>      if it contains AB then send mouseUp to button "NextTrack"
>      if it contains JL then send mouseUp to button "playpause"
>      if it contains JM then send mouseUp to button "back"
>      if it contains GK then send mouseUp to button "1"
>      if it contains HK then send mouseUp to button "2"
>      if it contains IK then send mouseUp to button "3"
>      if it contains GL then send mouseUp to button "4"
>      if it contains HL then send mouseUp to button "5"
>      if it contains IL then send mouseUp to button "6"
>      if it contains GM then send mouseUp to button "7"
>      if it contains HM then send mouseUp to button "8"
>      if it contains IM then send mouseUp to button "9"
>      if it contains HN then send mouseUp to button "10"
>      if it contains "IN" then send mouseUp to button "11"
>      if it contains GN then send mouseUp to button "12"

Well, first of all, I wouldn't name any buttons with numbers - it can
confuse Rev - use something like "B1" or whatever you like. And secondly, I
would put whatever is in "it" into some other variable so you can make sure
it doesn't get messed with.

My solution below uses B1-B12 instead of 1-12, and has put "it" into tData:

put it into tData
put "JK,AB,JL,JM,GK,HK,IK,GL,HL,IL,GM,HM,IM,HN,IN,GN" into \
  tPairs
put "NextTrack,NextTrack,playpause,back,B1,B2,B3,B4,B5," & \
  "B6,B7,B8,B9,B10,B11,B12" into tBtns
repeat with x = 1 to the number of items of tPairs
  if tData contains (item x of tPairs) then
    do "send mouseUp to btn " & quote & (item x of tBtns) & quote
end repeat

HTH,


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list