If with variables

Hello, and welcome to the forums.

That’s a tricky one! It’s always interesting to see advanced/complex templates - they’re good feedback to understand what features people are using, and it gives me ideas for improvement.

OK, so notable points in the template are..

Math expression using field value

<Math><Field number1 /> * <Field number2 /></Math>

Passing variable to tag attribute

The Get tag can be used to pass a variable to a tag attribute.

<Field name="{Get X}">

Inside the attribute, angle brackets <> need to be changed to {}.

Get/Set

<Set rangelow>...</Set>
<Set rangehigh>...</Set>

<Set X><Get type /></Set>
Set with dynamic name

The attribute name can be used to create a dynamic variable name.

<Set name="{Get X}_output">...</Set>

(This looks useful, I’ve added it to the documentation.)

If condition with variable

It’s possible to use the If tag with check attribute, and pass the variable to it.

<If check="{Get rangeone}">

Currently, L&L doesn’t have the equivalent of [if var=name] in CCS. I’ve made a note to add it, so we can do:

<If variable=rangeone>

(I think I’ll call the attribute variable instead of var.)

Field compare between values

Currently, there’s no simple way to compare between two values. The following operators exist, but can only be used one at a time, not combined:

  • more_than
  • more_than_or_equal
  • less_than
  • less_than_or_equal

Ideally, if we could combine them, your CCS code could be translated like this:

<If field=landarea more_than="{Get rangelow}" less_than_or_equal="{Get rangeone}">

OK, I’ve made a note to add support for this.