MegaBotopolis

Author Topic: Or Operator  (Read 97 times)

Offline Nymphis

  • Goblin Elite Warrior
  • ***
  • Posts: 22
Or Operator
« on: May 20, 2018, 06:05:23 AM »
Hi Jack

I have a Question regarding the "Or Operator"
In the instructions the Symbol used is |  but I can not seem to get this to work.

I have a simple "Loop While" command that looks like this.

Loop while (XX = False | AA = False)

Within this Loop While I am checking for the condition of XX and AA.
Theory is that the Loop with stop if either XX or AA = True.
I have checked the Global Variable XX and AA and the are changing correctly, but the loop keeps running even when if one of them is true.


I look forward to your feed back.

Offline Jack

  • Administrator
  • Goblin Zealot
  • *****
  • Posts: 15374
Re: Or Operator
« Reply #1 on: May 20, 2018, 04:00:55 PM »
If you want the loop to stop when either XX or AA is true then you set up the statement wrong.
Since you only want the loop to continue when they are both false you probably want to use an And operator instead.
It would prob be something like this:
Loop While (XX = False & AA = False)
if that doesnt work try this:
Loop While ((XX = False) & (AA = False))

Offline Nymphis

  • Goblin Elite Warrior
  • ***
  • Posts: 22
Re: Or Operator
« Reply #2 on: May 20, 2018, 04:39:32 PM »
Ah!  yes I see the Logic now :)
For the Loop while to stop i need it to see a false and the & Operator does this if either XX or AA is True.

one last question Jack, I assume I can only have 2 x expressions? one to the left and one to the right of &?
Or can I string 4 or 5 together?

Offline Jack

  • Administrator
  • Goblin Zealot
  • *****
  • Posts: 15374
Re: Or Operator
« Reply #3 on: May 21, 2018, 03:03:30 PM »
You can string together as many as you want. Check out the order of operations in most computer languages to see how a long expression will compute or just use brackets to organize it how you want it to be computed.

Offline Nymphis

  • Goblin Elite Warrior
  • ***
  • Posts: 22
Re: Or Operator
« Reply #4 on: May 22, 2018, 04:50:53 AM »
Cheers Jack :)