How TestStand Passes Parameters: By Reference vs. By Value

Updated Feb 2, 2026

Reported In

Software

  • TestStand

Issue Details

  • When I create a new parameter for my sequence, I see that in the TYPE column the type is followed by a (by reference) suffix. What does that mean?
  • What is the difference between passing a parameter by reference and by value?

Solution

When you pass data to a subsequence in TestStand, each parameter can be configured to pass by reference or by value. Understanding the difference is important for controlling data flow, preventing unintended side effects, and designing reusable sequences.

This article explains how both methods work and when to choose one over the other.

 

Pass‑by‑Reference (Default Behavior)

By default, TestStand passes parameters by reference. This means the parameter in the subsequence points directly to the variable in the calling sequence.

 

How it works:

  • No copy of the data is created.
  • The subsequence reads and **writes directly** to the caller’s variable.
  • Any change made inside the subsequence is reflected immediately in the calling sequence.

This behavior is similar to passing a pointer in C or wiring a control/indicator reference in LabVIEW.

 

Example:

In the Computer Mortherboard Test Example . The MainSequence passes Locals.CPUFail to the CPUFail parameter of the CPUTest subsequence:

  • The CPUFail parameter is a reference to Locals.CPUFail.
  • If the subsequence sets Parameters.CPUFail = True, the caller’s local variable becomes True as well.

Passing local variable by reference

 

When to use pass‑by‑reference:

  • The subsequence must update the caller’s variable (e.g., status flags, measurement results).
  • You want to avoid copying large data (e.g., arrays, container types).
  • You are intentionally modifying shared state.

Pass‑by‑Value

You can configure a parameter to be passed by value by right‑clicking the parameter and disabling Pass By Reference.

Changing to Pass-By-Value

 

How it works:

  • The caller’s value is copied into the parameter.
  • The subsequence operates on its own local copy.
  • Changes made in the subsequence do not affect the original variable.

Pass‑by‑value preserves data isolation and reduces unintended interactions.

 

When to use pass‑by‑value:

  • The subsequence should not modify the caller’s variables.
  • You want predictable, isolated behavior.
  • You want to enforce a “read‑only” data flow pattern.
  • You’re calling utility‑style sequences that should be independent of global or shared state.

Additional Information

Choosing Between the Two

Refer to the table below to understand the most suitable method for passing parameters to subsequences.

 

GoalRecommended
Allow subsequence to update the caller’s variablePass‑by‑reference
Prevent subsequence from modifying caller variablesPass‑by‑value
Avoid copying large data structuresPass‑by‑reference
Ensure subsequence is self‑contained and side‑effect‑freePass‑by‑value

 

A general guideline:

  • Use pass‑by‑reference intentionally, not accidentally.
  • If a subsequence should not modify input data, explicitly configure the parameter to pass by value.