Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Conditional statements

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

    Conditional statements

    This should be basic but cannot think straight, therefore need some help perhaps with the nesting of the conditional statements.
    For instance:

    if ( A && B && C) {
    BarColor }

    But after the initial statement, I would like BarColor to continue even if one of the conditions remains true. Thanks in advance...

    #2
    Hello 2Look4me,

    Thank you for your post.

    Set up a Color variable and set it outside your condition, but set the color to be used when your condition is true. For example:
    Code:
            #region Variables
    		private Color myColor = Color.Red;
            #endregion
    
            protected override void Initialize()
            {
    			
            }
    
            protected override void OnBarUpdate()
            {
    			if(myCondition) // myCondition is just a placeholder for your actual condition
    			{
    				myColor = Color.Blue;
    			}
    			
    			BarColor = myColor;
            }
    This will initially set the 'myColor' to Red, so the bar's are red until my condition is true - in which case the bars are now Blue.

    Please let me know if I may be of further assistance.

    Comment


      #3
      PatrickH, thanks for the fast response.

      Using your example:
      Code:
      if (A && B && C)
        {
                    myColor=Color.Blue;
        }
        BarColor  = myColor;
      I will have Blue bars when the conditions A, B and C are all true.
      But after my initial conditional statement (A && B && C), if A is no longer true, I would still want the bar colored Blue and if neither A nor B are true, but C is, I would still want the bar colored Blue. So if A, B and C are no longer true, the bars will be Red.

      Therefore my problem is with the subsequent conditional statements . Thanks again.

      Comment


        #4
        Hello 2Look4me,

        Thank you for your response.

        You would only need one more condition:
        Code:
        if(!A && !B && !C)
        {
        myColor = Color.Red;
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X