Jump to content
UBot Underground

[SOLVED] Loop While Condition


Recommended Posts

Hi all,

 

Here's a loop while condition I have set:

 

Loop While:

#Name1 != #Name2 OR #Address1 != Address2

 

So, essentially I want it to loop while either of those scenarios are equal.

However, it doesnt stop looping when the condition is met.

 

If I did those individually on their own like:

 

Loop While:

#Address1 != Address2

 

then it works fine.

 

loop while(#name1 != #name2 OR #address1 != #address2)

 

That's the code there.

 

What's wrong with my logic??

 

Thanks,

 

Kevin

Link to post
Share on other sites

Hi,

 

Try changing the OR to AND.

 

Kevin

 

As weird as tthat logic seems to be it does actually work.

 

Kevin, how is this so?

 

Thanks for that.

Link to post
Share on other sites

Hi,

 

Yeah I thought it would.

 

The use of !=.

Using OR both conditions would have to be met to exit loop while.

Using AND either one of the conditions are met it will exit loop while.

 

Kevin

Link to post
Share on other sites

AND and OR can be pretty confounding at first... never used EITHER... if someone has some free time I'm sure a tutorial highlighting usage and differences would be a welcome addition to the site... :)

Link to post
Share on other sites

Examples:

A = Oven = Kitchen Appliance

B = Fridge = Kitchen Appliance

C = Garage Door = Non-Kitchen Appliance

D = Vacuum Cleaner = Non-Kitchen Appliance

 

F = False = Logical Item

T = True = Logical Item

0 = False = Logical Item

1 = True = Logical Item

 

-------------

 

OR = EITHER

If ANY of the conditions is met, the result is TRUE

 

COMPARE Kitchen Appliances

A OR B = TRUE .... The Oven OR the Fridge are EITHER of them, Kitchen Appliances

A OR C = TRUE .... The Oven is a Kitchen Appliance while Garage Door is a Non-Kitchen Appliance, but at least ONE of them IS!

B OR C = TRUE .... The Fridge is a Kitchen Appliance while Garage Door is a Non-Kitchen Appliance, but at least ONE of them IS!

C OR D = FALSE .. The Garage Door OR the Vacuum Cleaner are none of them, Kitchen Appliances

 

Logical

F OR F = F = False OR False = FALSE

0 OR 0 = 0 (FALSE)

F OR T = T = False OR True = TRUE

0 OR 1 = 1 (TRUE)

T OR F = T = True OR False = TRUE

1 OR 0 = 1 (TRUE)

T OR T = F = True OR True = TRUE

1 OR 1 = 1 (TRUE)

 

-------------

 

AND = BOTH

If ALL the conditions at the same time are met, the result is TRUE

 

COMPARE Kitchen Appliances

A AND B = TRUE .... The Oven AND the Fridge are BOTH, Kitchen Appliances

A AND C = FALSE ... The Oven is a Kitchen Appliance; the Garage Door is a Non-Kitchen Appliance > NOT BOTH at the same time

B AND C = FALSE ... The Fridge is a Kitchen Appliance; the Garage Door is a Non-Kitchen Appliance > NOT BOTH at the same time

C AND D = FALSE .... The Garage Door AND the Vacuum Cleaner are none of them, at the same time, Kitchen Appliances

 

Logical

F AND F = F = False AND False = FALSE

0 AND 0 = 0 (FALSE)

F AND T = F = False AND True = FALSE

0 AND 1 = 0 (FALSE)

T AND F = F = True AND False = FALSE

1 AND 0 = 0 (FALSE)

T AND T = T = True AND True = TRUE

1 AND 1 = 1 (TRUE)

 

-------------

  • Like 2
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...