NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

variable name to string

Hi, I'm really new to TestStand, so this is probably an easy question:

 

I'm using TestStand 4.5 and I'm trying to convert the name of a variable, Locals.MaxArrayIndex, which is a numeric variable, into a String, Locals.VarString.

 

I know that the Str() function can be used to convert a numeric into a String, but how can I store the actual words "Locals.MaxArrayIndex" in a string?

 

Thanks! 

0 Kudos
Message 1 of 8
(6,616 Views)

You can use nameof() function to get the name of the array variable into string.

 example  -- Locals.strnum= NameOf(Locals.numarray)

You will need to append "locals." using "+" operator.

Message 2 of 8
(6,610 Views)

Thanks, that works great! For some reason it works for Locals, but I can't seem to get it to work for Parameters. Is there a different function that I have to use to convert Parameters to strings, or am I missing something?

0 Kudos
Message 3 of 8
(6,602 Views)

It should work for parameters also.

Please check attached TS 3.5 sample sequence.

0 Kudos
Message 4 of 8
(6,590 Views)

Ahhh, I see what my problem was. I was trying to do

 

Locals.name = NameOf(Parameters.value)

 

It didn't even cross my mind that you couldn't store the name of a Parameter in a Local.

 

Thanks, you've been a huge help! 

0 Kudos
Message 5 of 8
(6,555 Views)

Yes you can, it's only a string

eg

Locals.param_str2=NameOf(Parameters.param_num_array)

Regards
Ray Farmer
0 Kudos
Message 6 of 8
(6,552 Views)

Hmmm...it works great for Parameters that are arrays, but for me it won't work if the Parameter is a numeric variable. Maybe I'm making a mistake somewhere else that I'm not picking up; so I attached the sequence file if you want to take a look at it.

 

The issue arises in the 'Else' statement. I'm pretty sure the syntax in my function and popup are correct, but the String (ParamName) that is supposed to hold the value of the Parameter variable name (DataSelect) doesn't seem to ever be filled and outputted in the error message.

 

I would really appreciate it if any of you guys could have a look at the file (I'm sure I'm making some kind of really rookie mistake)

 

Thanks! 

0 Kudos
Message 7 of 8
(6,539 Views)

Hey saltlick,

 

I think I am able to get the results you desire just by changing the DataSelect to 11 and running your sequence file. See below. Both the ParamName string (DataSelect) and the ParamString string (11) are printed in the error message. How is this different then what you would like?

 

ERROR - Array Index out of bounds
Max Array Index is
Locals.MaxArrayIndex = 9
Index Requested is:
Parameters.DataSelect = 11

 

Luke W

0 Kudos
Message 8 of 8
(6,521 Views)