3 Replies Latest reply: May 4, 2012 7:42 AM by Philip Albert RSS

    MRL if...elseif statement

    Philip Albert

      Hi,

       

      I need to do a if...elseif statement but I can't make it compile.

      Anyone can help me out?

       

         if ($EV.mc_host contains 'domain1') then

         {

           $FLDS = strtolist($EV.mc_host, '.');

           $EV.IA_host = listgetelt($FLDS, 1);

         }

         else if ($EV.mc_host contains 'domain2') then

         {

           $FLDS = strtolist($EV.mc_host, '.');

           $EV.IA_host = listgetelt($FLDS, 1);

         }

         else if ($EV.mc_host contains 'domain3') then

         {

           $FLDS = strtolist($EV.mc_host, '.');

           $EV.IA_host = listgetelt($FLDS, 1);

         }  

         else

         {

           $EV.IA_host =$EV.mc_host;

         };

       

       

      Also tried with if...elsif   but it wasn't working

       

      Thanks,

      Philip

        • 1. MRL if...elseif statement
          Frank Thomae

          Hi Philip,

           

          try this one:

           

          if ($EV.mc_host contains 'domain1') then

          {

            $FLDS = strtolist($EV.mc_host, '.');

            $EV.IA_host = listgetelt($FLDS, 1);

          }

          else

          {

            if ($EV.mc_host contains 'domain2') then

            {

              $FLDS = strtolist($EV.mc_host, '.');

              $EV.IA_host = listgetelt($FLDS, 1);

            }

            else

            {

              if ($EV.mc_host contains 'domain3') then

              {

                $FLDS = strtolist($EV.mc_host, '.');

                $EV.IA_host = listgetelt($FLDS, 1);

              }  

              else

              {

                $EV.IA_host =$EV.mc_host;

              };

            };

          };

           

          I didn't have a chance to compile it, but it should work.

           

          HTH,

          Frank

          • 2. MRL if...elseif statement
            Oleg Protokolov

            Philip, Hi!

             

            In MRL there is no statement like IF-THEN-ELSEIF-ELSE

            There is only IF-THEN-ELSE

            Very sad about this ...

             

            In your case, use this compact MRL-code:

             

            if (  $EV.mc_host contains 'domain1'

               OR $EV.mc_host contains 'domain2'

               OR $EV.mc_host contains 'domain3'

               ) then

            {

              $FLDS       = strtolist( $EV.mc_host, '.' );

              $EV.IA_host = listgetelt( $FLDS, 1 );

            }

            else

            {

              $EV.IA_host =$EV.mc_host;

            };

             

            --

            Regards,

            Oleg

            • 3. MRL if...elseif statement
              Philip Albert

              Thanks Oleg, that's going to work. 

               

              Thanks Frank for your suggestion. I'll use Oleg's code, it's shorter.