01-01-2012 06:30 PM
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!
01-02-2012 12:30 AM
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.
01-02-2012 02:11 PM
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?
01-02-2012 11:14 PM
It should work for parameters also.
Please check attached TS 3.5 sample sequence.
01-04-2012 08:41 AM
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!
01-04-2012 09:24 AM
Yes you can, it's only a string
eg
Locals.param_str2=NameOf(Parameters.param_num_array)
01-04-2012 09:04 PM
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!
01-05-2012 04:32 PM
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