06-01-2011 04:05 AM
Hi.
I am trying to obtain the value of an array element in TestStand using the LabVIEW Get Property Value VI. My lookup string looks like this:
Locals.IdArray[RunState.TestSockets.MyIndex]
But it I get an error -17306, saying that RunState.TestSockets.MyIndex cannot be found. I know this is not true, since I have no problem accessing it from a TestStand expression executed in the step just before my LabVIEW step. I have tried to use a numeric value placed in Locals instead of the RunState variable, but the result is the same.
So my question is this: Can it really be true that I can only use a constant as index for an array when using the Get Property Value VI?
/Jens Christian Andersen.
Solved! Go to Solution.
06-01-2011 05:17 AM
The parameter required is string based as the name suggest therefore you have to match sure it's all in the format of a string
eg
"Locals.IdArray[" + str(RunState.TestSockets.MyIndex) + "]"
06-01-2011 06:10 AM
Thanks for you reply.
The way of writing the lookup string works well when I put it in to an expression in TestStand. But when I use it from within LabVIEW it does not work like I expected. I the VI is use a string control as input to the Get Property Value VI, and putting " " around the whole statement will not be like doing this ""<Variable>"" in a TestStand expression. So I tried to make it like this Locals.IdArray[" + str(RunState.TestSockets.MyIndex) + "] and this Locals.IdArray[str(RunState.TestSockets.MyIndex)] but it did not work.
Any suggestions on how to make this work correct from LabVIEW?
Regards
Jens Christian Andersen
06-01-2011 06:34 AM
Since you are using this lookup string in a module, not within TestStand itself, you cannot use string-parsing-capabilities from TS.
So your code has to look like something like this:
hope this helps,
Norbert
06-01-2011 10:04 AM
Let me try to clarify:
What you are doing (i.e. Locals.IdArray[RunState.TestSockets.MyIndex]) is fine from a teststand expression, but using a variable as an index does not work when you are just specifying a lookup string, you have to use an integer or string literal (if indexing an array of objects by name, but I don't think that's what you are doing in this case) instead. Probably the easiest thing to do is build a lookup string with the integer index hardcoded into it as Norbert is suggesting. Another possibility, but a more complex one, is to create a TestStand expression with your string in it and evaluate it programmatically using the current sequence context as the evaluation context.
Hope this helps,
-Doug
06-01-2011 10:36 AM
OK, it is just like it looked from the error message then. The PropertyObject methodes GetVal<Type> only passes the first statement and not recursive statements.
This look like I will be making my own version of the Get Property Value VI, which analyses the string for recursive expressions.
Thanks for your help.
Regards
Jens Christian Andersen.
06-02-2011 10:31 AM
1) This has nothing to do with recursive statements. Lookup strings are not expressions. They are just the location of a subproperty or element.
2) If what you want is expression evaluation, there is no need to create such a thing from scratch. You can use the TestStand API to execute an expression rather than using the lookup string feature if that is the behavior you want. For example this is what it would look like in a text based language:
double mynumber = mySequenceContext.AsPropertyObject().EvaluateEx("Locals.myarray[Locals.myindex]", EvalOption_DoNotAlterValues).GetValNumber("", 0);
Hope this helps,
-Doug
06-06-2011 02:36 AM
Thanks Doug.
This is what I was looking for. Sice this is to be used in the setup GUI of a custom step type, I want it to look as simple as possible to the user of the step type, and at the same time be flexible enough to handle a variable as array index.
Regards
Jens Christian Andersen.