NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with EvaluateEx Method used to store Reference to new execution

Solved!
Go to solution

So, I've been tinkering with running sequences in a new execution. My goal is to store a reference to the execution in a variable, which works pretty well with variables (locals in this case) which have been created during development.

In order to make things more complicated 🤔 I am creating the (local) variable for the reference dynamically during runtime using the API.

The issue comes up, when trying to dynamically assign the newely created variable as the storage for the exec refnum in the sequence call.

 

Oli_Wachno_1-1679404441542.png

Note: the screenshot basically shows a fix variable name in order to make debugging easier. The Expression I am using is working. I am using the exact same expression in other places within my demo sequence (pls. refer to attachment).

When runing the sequence, the sequence call is executed without any run-time errors, the issue is that Locals.Sample_Exec_Ref is obviously not accessed by the sequence call, as can be observed by using breakpoints and inspecting the variables during runtime.

 

So... where do I go wrong here?

 

Cheers

Oli

 

 

0 Kudos
Message 1 of 5
(1,582 Views)

Will it work if you replace the method with the Evaluate() function?

 

BTW why do you need to use evaluate in the first place? The name is generated dynamically?

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
Message 2 of 5
(1,566 Views)
Solution
Accepted by Oli_Wachno

EvaluateEx() returns a reference object that refers to the result of the evaluation. To get to that result, deference the reference with a *.  Example:

 

*ThisContext.AsPropertyObject.EvaluateEx("Locals.Same_ExecRef", 0)

Message 3 of 5
(1,558 Views)

James, thanks for clarifying this!

Questions like this can only come from a by-value guy 😅

 

I wasn't aware of the existence the dereference operator up to now!

Oli_Wachno_0-1679469196155.png

 

For the records, I have attached the corrected version of the sequence file in case anybody wants to do similar complicated things.

 

 

0 Kudos
Message 4 of 5
(1,529 Views)

@bienieck wrote:

Will it work if you replace the method with the Evaluate() function?

 

BTW why do you need to use evaluate in the first place? The name is generated dynamically?


Michal,

 

exactly, the name is to be created dynamically. I was using a fixed string to make the example easier.

Use case is the definition of custom step type, with which I want to make using new execs less error prone.

0 Kudos
Message 5 of 5
(1,526 Views)