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?
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 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.
@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)