Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:16:21+00:00 2026-06-05T04:16:21+00:00

i’ve came across a simple loop which seems to go into the loop regardless

  • 0

i’ve came across a simple loop which seems to go into the loop regardless of a parameter i query in order to determine whether the loop should process. Below is the loop;

  if (result[4] == 0x01 || result[5] == 0x01 || result[6] == 0x01 || result[7] == 0x01 || result[8] == 0x01 || result[9] == 0x01 & deviceState == false)
                {

                        deviceState = true;
                        mainUI.setAlarmColour(result, device);

                }

note: i’ve tried “&” and “&&” for the final parameter, but both make no difference.

With this loop, even if deviceState is set to true, it proceeds to enter the loop. However, if i use the following loop it stops this issue:

  if (result[4] == 0x01 || result[5] == 0x01 || result[6] == 0x01 || result[7] == 0x01 || result[8] == 0x01 || result[9] == 0x01)
                {
                    if (deviceState == false)
                    {
                        deviceState = true;
                        mainUI.setAlarmColour(result, device);
                    }
                }

This second loops solves the problem and it no longer proceeds into the loop, meaning my function isn’t called.

am I missing something fundamental here? I’ve tried messageBoxes to verify that it’s false and they return the way I’d expect, yet it still enters the first loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:16:22+00:00Added an answer on June 5, 2026 at 4:16 am

    First it’s && like you already tried (& is a bitwise operator), but you should group your ORs together and have the final AND standalone, like so:

    if (
        (result[4] == 0x01 || result[5] == 0x01 || result[6] == 0x01 ||
         result[7] == 0x01 || result[8] == 0x01 || result[9] == 0x01)
       && deviceState == false)
    {
        deviceState = true;
        mainUI.setAlarmColour(result, device);
    }
    

    Note that you can also change deviceState == false to simply !deviceState (if it’s a non-nullable bool). ! flips false to true for the comparison so you’re essentially saying the exact same thing, albeit shorter.

    (Please ignore ugly formatting, just trying to show it clearer)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.