NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Locals.StartMarker expression syntax

Locals.StartMarker = (RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 1) ? "Commercial Grade Specifications" : "Military Grade Specifications"
Locals.StartMarker = (RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 1) ? "Commercial Grade Specifications" : "Military Grade Specifications"  : "My Grade Specifications"

When I add a third button to specify a third set of vars in the .\TestStand 3.5\Examples\Loading Limits\LimitsFromTextFile, TestStand gives me a syntax error on the ":" between the second and third ( and new) test condition.

I have searched for a syntax guide for expressions. Is there an expression guide for these types of constructs?

0 Kudos
Message 1 of 5
(2,856 Views)
Ok,  I now see this is the ? : operator that only chooses between two expressions. and trying to add a third is not appropriate.

I'll look for another example on how to do this with more than two buttons to choose between.



0 Kudos
Message 2 of 5
(2,852 Views)
Hi,
 
If you what to expand the expression try something like this
 
Locals.StartMarker = (RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 1) ? "Commercial Grade Specifications" : ((Locals.StartMarker = (RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 2) ? "Military Grade Specifications"  : "My Grade Specifications")
regards
Ray Farmer
Regards
Ray Farmer
Message 3 of 5
(2,848 Views)

Linefeeds (try ctrl-enter) can make it easier to read. Also, there is no need to repeat the assignment:

 

Locals.StartMarker =

(RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 1) ? "Commercial Grade Specifications" :

(RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit == 2) ? "Military Grade Specifications"  :

"My Grade Specifications"

 

A local variable can make it easier to read, especially if there are a lot of cases:

 

Locals.buttonHit = RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit,

Locals.StartMarker =

(Locals.buttonHit == 1) ? "Commercial Grade Specifications" :

(Locals.buttonHit== 2) ? "Military Grade Specifications"  :

"My Grade Specifications"

 

An lookup table array can also make it simpler:

Locals.StartMarker = Locals.MyMarkers[RunState.Sequence.Setup["Identify Limits to Use"].Result.ButtonHit]

 

(note, I didn't actually test these, so they might need some slight adjustment).

Message 4 of 5
(2,838 Views)
Nice touch James
Regards
Ray Farmer
0 Kudos
Message 5 of 5
(2,823 Views)