Skip to content

If Variable Command

Majenko Technologies edited this page Feb 1, 2016 · 1 revision

The if variable command simply compares two string values. If they are the same a new "true" value is inserted, otherwise a "false" value is inserted.

The format is:

${if:lval=rval,trueval,falseval}

If lval and rval are the same the function is replaced by trueval otherwise it is replaced by falseval. For instance:

${if:${board:name}=arduino-uno,Arduino Uno,Unknown Board}

This example makes use of the inside-out recursive nature of the string parsing. First the token ${board:name} is parsed and replaced by the current board code-name, and then the ${if...} is parsed with the newly replaced board name in it.