having difficulty to understand this while loop?

46 views Asked by At

I have difficulty understanding this while loop:

enter image description here

1

There are 1 answers

1
Donal Fellows On

The Condition

The condition:

while {1 == [string equal $result Completed]} {

could be written more shortly as:

while {$result eq "Completed"} {

That is, it means "do the body while $result is equal to the literal string Completed.

The Body

The body of the loop calls $mode run (what exactly that does isn't described here). Then it gets the result by calling $mode getRunResult and extracts the first word of the list, and assigns it to the variable result. The final step of the loop is to use switch to print a message whenever $result is either Error or SolverFailure (it also has clauses for Completed and StopCritera, but that's empty so nothing happens).

The Overall Effect

The loop calls $mode run until the first word of the result of $mode getRunResult after that run is not Completed.

$mode is a handle returned by pw::Application begin ExtrusionSolver $block, and $mode end is called after the loop terminates, presumably to clean things up.