Pre-condition Does Not Evaluate Correctly Using Global Variables

Updated Oct 22, 2018

Reported In


  • TestStand

Issue Details

When setting a pre-condition to evaluate based off a global variable, it does not execute as I would expect.


By default, TestStand stores global variable values in the .ini file. Because of this the global is not reinitialized on every execution, rather, it only changes when you specify in the sequence file.  

For example, assume you have the following settings in a step referencing a Boolean global variable "Did_It_Run" = False:

Precondition - StationGlobal.Did_It_Run == False
Post Expression - StationGlobal.Did_It_Run = True

The step above would execute only once, regardless of how many times the code executes, since the value is changed to True and is not reset. You have two solutions to that problem: 
  1. Use a local variable. This will reset to its default value on every execution so when the sequence begins it will always be false, ensuring one execution of the step every time you execute the test sequence. 
  2. Reset the global variable somewhere before the code finishes executing. You can do this in the cleanup section to ensure it happens only once. A statement step with syntax "StationGlobal.Did_It_Run = False" will accomplish that. 

Additional Information

The TestStand Deployment Utility does not automatically deploy the station global variables. You can include the StationGlobals.ini file in the deployment image, but doing so might remove any station global variables that exist on the target computer to which you deploy the image.


Not Helpful