Passing Data to a Subsequence with Parameters in TestStand

Updated Feb 21, 2020

Reported In

Software

  • TestStand

Issue Details

I've created a subsequence that requires data from the main sequence. How do I pass this data?

Solution

In TestStand, data can be passed from a sequence to a subsequence with parameters using the following steps. In this example, we will create two sequences and pass data from one sequence to another using parameters.
  1. Create a new sequence file.
  2. In the Sequences pane, right-click and select Insert Sequence. Rename this new sequence to Subsequence.

 
  1. With Subsequence selected, move down to the Variables pane and create a new parameter.
    1. Right-click Parameters ('Subsequence') and select Insert Parameter > Number.
    2. Rename this parameter to DataToRead.

 
  1. With MainSequence selected, move down to the Variables pane and create a new parameter.
    1. Right-click Parameters ('MainSequence') and select Insert Parameter > Number.
    2. Rename this parameter to DataToWrite.
    3. Change the value to any number other than 0. In this case, we'll enter 99 to be easily identifiable.

 
  1. With Subsequence selected, drag a Message Popup into the Main step, where it says <Insert Steps Here>.

 
  1. With the Message Popup selected, change the message expression to: The value of DataToRead is: " + Str(Parameters.DataToRead)

 
  1. With MainSequence selected, drag a Sequence Call into the Main step, where it says <Insert Steps Here>.

 
  1. With the Sequence Call selected, look down to the Step Settings for SequenceCall pane.
    1. check the Use Current File box.
    2. In the Sequence drop-down, select Subsequence.
      1. The Parameter Name should now auto-populate with DataToRead.
    3. For the Value input, type Parameters.DataToWriteThis will pass the value that is in DataToWrite (99) to DataToRead.

 
  1. Select Execute > Run MainSequence from the top toolbar. 

 
  1. Save the sequence file and observe the message popup, which says The value of DataToRead is: 99

This popup box demonstrates that we have successfully passed a numeric value from the main sequence to the subsequence. The same methodology can be used for more complex operations. 
 

Additional Information

Passing By Reference 
If a parameter is not specified By Reference, when the subsequence is called, a copy of the data is made and the copy is passed to the subsequence. The subsequence can modify the copy of the data while the calling sequence will have the unmodified original data.

Must I Use Parameters to Pass Data? 
You can use StationGlobals or FileGlobals to pass data from one sequence to another. However, parameters provides for orderly passing of data from one sequence to another sequence. If you are running parallel executions, parameters are essential to prevent corruption of data by limiting scope.