Jump to content

Opposite expression help


rpaterick

Recommended Posts

I need the code below to state the opposite as it is currently. If the field does not contain the value "Commercial," then return value.

 

if (Field("version").indexOf(String("Commercial")) > -1)
{
  return "<span>" + Rule("Day of the Week") + "</span>";
}

return "";

Thanks!:confused::(

Link to comment
Share on other sites

I need the code below to state the opposite as it is currently. If the field does not contain the value "Commercial," then return value.

 

if (Field("version").indexOf(String("Commercial")) > -1)
{
  return "<span>" + Rule("Day of the Week") + "</span>";
}

return "";

The simplest way to turn an if/else statement (which is basically what this is, although you're using a return statement to imply the "else") into its "opposite" is to simply swap the "if" and "else" blocks, like so:

if (Field("version").indexOf("Commercial") > -1)
 return "";
//else
return "<span>" + Rule("Day of the Week") + "</span>";

Or, you can change the logic in the comparison thusly:

if (Field("version").indexOf("Commercial") [color=Red]==[/color] -1)
 return "<span>" + Rule("Day of the Week") + "</span>";
//else
return "";

Link to comment
Share on other sites

The simplest way to turn an if/else statement (which is basically what this is, although you're using a return statement to imply the "else") into its "opposite" is to simply swap the "if" and "else" blocks, like so

 

Nice! Thanks Dan!:cool:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...