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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      82 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      43 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Working...
      X