Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trouble with conditional else

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    trouble with conditional else

    I have control code like below. All my prints are good. I can print breakfast, lunch, dinner. But I cant get the else to print go for a walk. What am i doing wrong? its like the else doesn't see the if's. Thanks all.

    if (bool1 true)
    {make breakfast}
    else if (bool2 true)
    {make lunch}
    else if (bool3 true)
    {make dinner}
    else
    {go for a walk}

    #2
    Hi Kicks.Spin, thanks for your post.

    The last else will only print if all the above ifs evaluate to false. Make sure all 3 booleans are false then go for a walk should show up.

    Best regards,
    -ChrisL

    Comment


      #3
      thank you ChrisL. the above ifs did evaluate to false. i got it. looks like i needed to bracket the else inside the if brackets.

      if (bool1 true)
      {
      {make breakfast}
      else if (bool2 true)
      {make lunch}
      else if (bool3 true)
      {make dinner}
      else
      {go for a walk}
      }
      Last edited by Kicks.Spin; 05-12-2021, 10:08 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      71 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X