NetXMS Support Forum

English Support => General Support => Topic started by: lindeamon on August 21, 2011, 06:44:13 PM

Title: if statement
Post by: lindeamon on August 21, 2011, 06:44:13 PM
hi,

i am trying to right a very simple transform script which will take the $1 variable and change it's value to "yes" if it is equal to 1 and "no" if it is equal to 2.
i can get through the first comparison but other then that nothing works and the user manual does not help.

10x,
lindeamon
Title: Re: if statement
Post by: Victor Kirhenshtein on August 22, 2011, 12:05:47 AM
Hi!

Script for this cold looks like following:


if ($1 == 1)
   return "yes";
if ($1 == 2)
   return "no";
return "neither_yes_or_no";


or, using switch operator:


switch($1)
{
   case 1:
      return "yes";
   case 2:
      return "no";
   default:
      return "neither_yes_or_no";
}


Best regards,
Victor
Title: Re: if statement
Post by: lindeamon on August 22, 2011, 10:13:34 AM
thank you victor,
i kind of solved it myself yesterday with if loops but your answer taught me cleaner ways.

regards,
lindeamon