Using variables in a condition and incrementing them too

Stimulsoft Reports.JS discussion
Post Reply
notme
Posts: 4
Joined: Mon Mar 11, 2024 1:19 pm

Using variables in a condition and incrementing them too

Post by notme »

Hi,

I would like to output something in a text object depending on a variable value with a condition and increment the variable in the same step. The (non-working - syntax error) expression looks like this:

{condition ? "" : start + offset; offset = offset +1}

It should output nothing, if condition is true. If not, it should output start+offset and increment the offset after.
Is there a way to do this with one text object?

As workaround, I use this expression:
{condition ? "" : start + offset}
and a second text object with this expression:
{condition ? "" : offset = offset +1}
and hide its output by using an empty text brush :oops:

thanks!
Christian
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Using variables in a condition and incrementing them too

Post by Lech Kulikowski »

Hello Christian,

You can use the following expression:
{condition ? 0 : start + offset++}

Thank you.
Post Reply