need help with the flow of a program

here`s what i want to accomplish.
if z > 500
then do this
// if a > b
then light up light “A”
// while a > b
keep the light “A” on
// if during this time c becomes greater than d (c > d)
turn light “B” on
turn light “B” off (which makes a < b by default)
turn light “A” off

i have tried to do it, but as z > 500 light “A” keeps flashing on and off regardless of the behavior of c and d. must have the flow wrong. looking for more of a guide to the flow of the programming rather than a complete syntaxtical breakdown.

thank you
arduiYES

turn light “B” off (which makes a < b by default)

The comment in the parentheses does not compute. Turning an output pin on or off has no effect on the sensor use to determine if the pin should be on or off.

Your other thread on this same topic starts off with a while statement. Do you understand the difference between a while statement and an if statement?