user3565150
user3565150

Reputation: 914

Error in checking variable in while loop

I am trying to check the value of a variable in a while loop

 set resultReturn 0
 while {expr $resultReturn == 0} {
    # Apply the stream configurations.
    set resultReturn [stc::apply]
 }

I am getting the following error:

syntax error in expression "expr $resultReturn == 0": variable references require preceding $

What should be the correct way to check the variable in an infinite loop until it changes value from 0?

Upvotes: 0

Views: 289

Answers (1)

Brad Lanam
Brad Lanam

Reputation: 5723

While takes a test as its first argument and processes it in the same manner as expr.

while { $resultReturn == 0 } {

References: while

Upvotes: 3

Related Questions