Using multireplace to check more than one variable

As the title indicates, I’m trying to figure out if I can use multireplace to check more than one variable in the same statement.

Basically I have two variables (call them a and b) that can be true or false. Is there a way to use multireplace so that if either of them is true to display text x, and if both are false display text y?

I haven’t tested it, but maybe try @{(var_a or var_b) yes|no}

Edit: After testing, it seems to work as expected.

2 Likes

Well since you’re using an OR it’s simpler. If you were using an AND and wanted to cover all four possibilities possibilities (as in all states of A and B), it would require a different approach.

@{((var_a = true) or (var_b = true)) what to display if any of them are true|what to display if any of them are false}.

(You can also remove the “= true” and just use (var_a) instead, I just added those for clarity.)

If you want to cover for all four possibilities in an AND it would be different as you can’t nest multireplaces together. But I can show two ways if you’re interested.

Here is more info on multireplace if you’re interested:

That’s…much simpler than I expected! Thanks, I’ll plug that in and give it a whirl as soon as I get home!

That mostly works, though you need another parenthesis around (var_a = true) or (var_b = true), or else the multireplace will misinterpret the positive result as:

or (var_b = true) what to display if any of them are true

Yeah, that gets a little silly. Instead, it should look like so:

@{((var_a = true) or (var_b = true)) what to display if any of them are true|what to display if both of them are false}

Edit: This is how you’d do it if your variables weren’t Boolean (true/false). For string or numeric variables, you’ll check them with nested parentheses like this.

1 Like

Thanks for the correction, forgot to include the extra set of parenthesis.

@GoldenSilver thanks! I think I was replying at the same time you were.

I do a lot of my writing at work (shh) where I can’t actually test things in CSIDE so I just fill in code from memory as I go then copy/paste and fix indents at home. This one was vexing me so I figured I’d ask the knowledge base here on the forums (which is fantastic btw… I’ve always gotten an answer to even my dumb questions)

1 Like