Page 1 of 1

if condition1 or condition2 or condition3 then...

Posted: Sun Jun 15, 2014 8:48 pm
by jalz
Hi Guys,

Is there a neat way of writing if with two or statements? I'm sure I can write nested ifs or a switch/case, but is there a more succinct way of writing this with an if statement?

Thanks
Jalz

Code: Select all

      put the long id of control x into tLong
      if (tLong contains "field" AND tLong contains "group") OR  
      (tLong contains "button" AND tLong contains "group") OR
      (tLong contains "graphic" AND tLong contains "group") 
      then
         //do something
      else
         // do something else
      end if
Thanks

Re: if condition1 or condition2 or condition3 then...

Posted: Sun Jun 15, 2014 9:03 pm
by bn
Hi Jalz,

you could write:

Code: Select all

   put "field,button,graphic" into tObjects
   put the long id of control x into tLong
   
   if tLong contains "group" AND  word 1 of tLong is among the items of tObjects then
      //do something
   else
      // do something else
   end if
Kind regards
Bernd

Re: if condition1 or condition2 or condition3 then...

Posted: Sun Jun 15, 2014 9:17 pm
by jalz
Hi Bernd

Thats a really elegant way of doing it! I can easily increase the tObjects keywords if I need to with the minimal of fuss

Many thanks
Jalz