If with variables

Super new here… but I use CCS extensively. In many instances we calculate a value and store it as a variable in CCS
[set x][get type][/set]
[set rangelow][calc][field number1] x [field number2][/calc][/set]
[set rangeone][calc][field number3] x [field number4][/calc][/set]

Then use that variable in an IF statement
[pass vars]
[if var=rangeone]
[-if field=“landarea” compare="<=" value="{RANGEONE}" and compare=">" value="{RANGELOW}"]
[set {X}output][get rangelowcalc][/set]
[/if]
[/pass]

How do I do that with loops & logic??

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.

Eliot - Thank you for the help. Need to read more on the Tag attribute. I would LOVE to have variable back. We calculate a lot of variables up front then run comparisons to determine valid post results. Field compare between values is also very useful.

This by far is one of the easier examples in the system we built. The entirety of it is a tool that allows you to pass a set of variable ranges from a field and evaluate the conditions to determine which calculation to run based on the size or width of a property. Basically wrote an entire matching engine that analyzes a piece of real estate, determines the zoning requirements for the property, evaluates the constraints based on the zoning code, then matches the home plans that can be built on the property and prices the home plan based on municipal requirements. To say I’m scared to death of the end of life of CCS is an understatement.

I see, it sounds like you’ve made extensive use of CCS shortcodes, not only for templating but more like a programming language. I’m confident you’ll find that L&L is even better designed for this kind of advanced use cases.

It’s probably best to gradually convert the matching engine and calculation logic, part by part, until the whole system is upgraded.

There are still CCS features that don’t have equivalent functionality in L&L yet, so we’d love to continue discussion on various aspects of the migration.

Hi David,

In the newest plugin version, it now supports a shortcut for checking if a variable has value:

<If variable=rangeone>

And field comparison between values, combining more_than, less_than, etc.

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

I’ll have to play with this a bit. Gonna need to understand from the documentation how variables are set / get but so far I LOVE it.