NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting specific elements of a string

Solved!
Go to solution

I'm working on a program that requires a certain sequence of outputting from a string. In python, I am able to use this line to select the last 2 elements of the string to be added to the first 2 elements of the string to form the output

sl=str(z1)

sll=sl[-2:]+sl[:2]

 

Any idea how to replicate this in teststand. 

Locals.hextstr=Str(Locals.y1,"%x"), Locals.hextstr2=Str(Locals.y2,"%x"),Locals.s=Locals.hextstr+Locals.hextstr2

I need to get the last 2 elements from hexstr and then to be followed by the first 2 elements of hexstr and repeat this for hexstr2 also

0 Kudos
Message 1 of 4
(4,463 Views)
Solution
Accepted by topic author tonye546

TestStand has two functions, Left() and Right(), that you can use to extract some characters from the beginning and end of a string.

 

Let's say you have Locals.String = "12abcdef34"

 

and that you display the following code in a message popup: Left(Locals.String,2) + Right(Locals.String,2)

 

you would get: 1234

Marc Dubois
0 Kudos
Message 2 of 4
(4,439 Views)

Use left() and right() string functions.

Have you looked at available functions for teststand expressions? The expression browser list all available functions.
Expression_browser.PNG

0 Kudos
Message 3 of 4
(4,437 Views)

Thank you. That was very helpful

0 Kudos
Message 4 of 4
(4,402 Views)