I have a ‘passes’ variable that indefinitely counts the while loop until While(Boolean) condition is met. Is it normal for passes (global variable) to not update in the ‘Run’ screen whilst the program is correctly looping in the While loop? Variable updates correctly once it exits the while loop.
I tried using a thread to force update passes = passes in it’s own While(Boolean), still doesn’t work while force() variable in the same thread updates perfectly.
Example code, ignore the etcetcetc:
global passes
global fforce
While(Boolean):
etcetcetc
passes = passes +1
sync()
end
thread update()
while(Boolean):
fforce = force()
passes = passes
sync()
sleep(.1)
end
end
And run updated() is executed long before it gets to the etcetcetc while loop
This code example needs to be refactored - I completely can’t understand it.
passes = passes does nothing.
Do you actually start update thread - just defining it will not start it automatically.
passes = passes was an effort get ‘passes’ updated in the variables section in the ‘Run’ Tab. The code is just a snippet of where passes = passes + 1 is happening.
Try this:
global passes
While(Boolean):
etcetcetc
passes = passes +1
sync()
end
As I said in the last line, yes - I start the update thread. Now just ignore the thread and only look at the while loop with passes = passes+1. Why doesn’t passes update in the variables section of ‘Run’ tab in polyscope when it’s it it?
Only when Boolean condition is met and while loop is completed ‘passes’ variable is updated in the Run screen. Everything is working as designed. I’m just trying get live view of the ‘passes’ variable on the screen w/o having to textmsg() it on the logs every loop.
Does anything change if you assign passes an initial value? (ie use global passes = 0) In short, no I can’t think of any reason that variable wouldn’t be updating live in the Variables section. But I’ve seen some odd behavior when you let the compiler choose datatypes by not explicitly defining them with an assignment.
Sorry, forgot. Yes, passes is initialized to 1 at the start (global passes = 1).
hmm since you mentioned datatypes, I might try to pass a to_str() and a list to a different global variable and see if that gets updated in the same while loop.
@eric.feldmann Genius. Thank you for mentioning data types. int/float doesn’t update for some reason, but string and list does!
Yea, must be a bug of some sort.. I mean, ‘passes’ is certainly updating within the code. The updated value just didn’t reflect on the variables section in the ‘Run’ tab until the loop was done.
Could you come up with minimal script that can reproduce the issue?
I’m running on latest pre-release 5.23, and I can’t see any problem with updating list of variables:
That’s pretty much exactly it. only difference is that it’s in a before start def script and robot program script is calling it out. I’m on 5.21.3 March 14 2025
before_start.script
global passes = 0
def call(pass):
passes = pass
while(True):
passes = passes 1
end
end