NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

string tokens

Solved!
Go to solution
Hello, I have a string that looks something like "cmd_name cmd_arg" where the "cmd_name" is separated from "cmd_arg" by a space character. Is there a quick way in TestStand to separate the entire command string into substrings tokens and using the space character as a delimiter, similar to the strtok() function in C++?
0 Kudos
Message 1 of 3
(3,179 Views)
Solution
Accepted by topic author JulesG

This is really a job for a code module in your programming language of choice such as LabVIEW, C#, C, or C++.

 

However, if you want to keep it all in TestStand, the following statement step will extract cmd_arg into Locals.Token:

 

Locals.Expression = Engine.NewExpression(),

Locals.Expression.AsExpression.Text = "cmd_name cmd_arg",

Locals.Expression.AsExpression.Tokenize(0, 0),

Locals.Expression.AsExpression.GetToken(1, 0 /*unused*/, 0 /* unused */, 0 /* unused */, Locals.Token)

 

you'll need to create Locals.Expression as a reference and Locals.Token as a string.

Message Edited by James Grey on 06-15-2009 01:43 PM
Message Edited by James Grey on 06-15-2009 01:44 PM
Message 2 of 3
(3,176 Views)
Thanks James, the code you prvided does what I need it to do.
0 Kudos
Message 3 of 3
(3,169 Views)