Variable defined in BLYNK_WRITE() function will not respond to the widget command except within the BLYNK_WRITE function

When I use BLYNK_WRITE to write to my hardware the value in the variable I created responds to the widget push button with a 1 or 0, but if I call that variable up outside the BLYNK_WRITE function it does not respond.
Here’s an example of the code:
int demand;
demand = param.asInt();
Serial.print("get value ");

void loop()


In this example I can see in the serial port the demand variable changing , but it wont change in the void loop() .
I want to make a program decision based on whether I have a 1 or a 0.

Have you defined demand as a global variable?

Yes I tried that. It does not make difference.

I discovered that the variable did respond when it was in the void loop
because I had a delay in that loop. I removed the delay and now the variable responds to the push button widget.

I meant to say the variable did not respond when it was in the void loop because of the delay.
With the delay removed its working.

you need to set the demand flag to 1 in the BLYNK_WRITE, and then change tit back to 0 in the loop, after processing something if it was 1…