# What if I had all the ifs?

**URL:** <https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142>\
**Category:** ChoiceScript Help\
**Created:** [March 18, 2023, 8:26am UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142 "2023-03-18T08:26:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sinnie](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@Sinnie](https://forum.choiceofgames.com/u/Sinnie)\
**Post date:** [March 18, 2023, 8:26am UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142/1 "2023-03-18T08:26:03Z")

</div>

I am working on a little side project to build a test tool for Choicescript. I was hoping that the lovely community could help me out.

The \*IF command can take lots of different structures of brackets, ands, ors and variables and I’d like to compile a nice library of valid commands that I can validate my code against. Whilst I can construct my own examples, it’s useful to have real examples that my tool would need to correctly parse.

Could you please innundate me with examples of \*IF commands from your code?

Whilst I only need one example of each unique structure (e.g., \*IF (cond\_a or cond\_b) and cond\_c) - It’s probably easier to just dump your examples here and for me to sift and categorise them afterwards.

---

<div class="post-metadata">

**Author:** ![StephenHart](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stephenhart/32/160392_2.png) [@StephenHart](https://forum.choiceofgames.com/u/StephenHart)\
**Post date:** [March 19, 2023, 1:40am UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142/2 "2023-03-19T01:40:35Z")

</div>

I think rather than a number of examples, the main thing you need to check is that there is an equal number of left and right parentheses and that no pair of parentheses contains more than two choices. (this is one of the pains of choice script but that’s the way it is).

Thus, the following are really all the same check - one rule covers them all:  
(a or b)  
((a or b) or (c and d))  
(((a or b) or (c and d)) or (d and f))  
etc

Writing a program to make this check is left as an exercise for the reader (ahem). There may be some hideously fiendish regular expression that does it but that’s beyond my skills.

(Note: the choice script interpreter must make this check - I don’t know whether that code is available, or whether one of the authors might give you a hint)

---

<div class="post-metadata">

**Author:** ![will](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/will/32/132033_2.png) [@will](https://forum.choiceofgames.com/u/will)\
**Post date:** [March 19, 2023, 8:52am UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142/3 "2023-03-19T08:52:14Z")

</div>

> [@Sinnie](#):
>
> I am working on a little side project to build a test tool for Choicescript.

Like, test that the code works correctly?

Here’s how I’d structure this program:

```choicescript
run quicktest.html
print results

```

---

<div class="post-metadata">

**Author:** ![Nahim\_Kerman](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nahim_kerman/32/62734_2.png) [@Nahim\_Kerman](https://forum.choiceofgames.com/u/Nahim_Kerman)\
**Post date:** [March 20, 2023, 12:58pm UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142/4 "2023-03-20T12:58:00Z")

</div>

Actually. In theory Choicescript IDE does that in execution time. Highlighting the brackets as you type them.

I say in theory because that feature is a little buggy.

There is a glitch in choicescript IDE that makes the application consider a " ] " as if it was the same of a " ) ". And that causes some errors…

---

<div class="post-metadata">

**Author:** ![StephenHart](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stephenhart/32/160392_2.png) [@StephenHart](https://forum.choiceofgames.com/u/StephenHart)\
**Post date:** [March 22, 2023, 1:13am UTC](https://forum.choiceofgames.com/t/what-if-i-had-all-the-ifs/134142/5 "2023-03-22T01:13:55Z")

</div>

Useful. Can it also check the ‘rule of two’ because that’s the tricky one - i.e. pick up that ((a or b) or (c and d) and (e and f)) is incorrect?
