Search code examples
tinybutstrong

Nested conditionals or some such


I need to do something like:

[onshow;if [onload.project.sortBy]='Id';then if [onload.project.sortAscending]=1;then '↓';else '↑']

But, perhaps as expected, ↑ is always displayed.

What's the alternative here?

Thank you and be well.


Solution

  • The expression then if is not support by TBS.

    You're trying to perform a AND operation between ([onload.project.sortBy]='Id') and ([onload.project.sortAscending]=1) but TBS does not support logical operators.

    So here are 3 workarounds:

    1) Solution using multiple if/then parameters :

    [onshow;if '[onload.project.sortBy]'!='Id';then '↑';if [onload.project.sortAscending]=1;then '↓';else '↑']
    

    2) Solution by simulating AND with concatenation :

    [onshow;if '[onload.project.sortBy]-[onload.project.sortAscending]'='Id-1';then '↓';else '↑']
    

    3) Solution using custom variable :

    [onshow;if '[onload.project.sortByIdAscending]'='1';then '↓';else '↑']