Execution of persistent variables:
The functions can also be called from the script or from the Command Window, as shown here. For illustration, the functions are called first from the script. With the persistent variable, value of count is incremented. Then, the func1 is called from Command Window, & func2 is also called from Command Window. As the value of the persistent variable had the value 2, at this time it is incremented to 3.
This is what occurs with a normal variable:
The value of count is 1
This is what occurs with a persistent variable:
The value of count is 2
The value of count is 3
As it can be seen here, that each and every time the function func1 is called, whether from the persistex or from Command Window, the value of 1 is printed. Though, with func2 the variable count is incremented each and every time it is called. It is first called in this illustration from persistex twice; therefore the count is 1 and then 2. Then, whenever called from the Command Window, it is incremented to 3. Obviously, the numbering of the error messages will carry on if the function is executed again.