From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Array of numbers into well formatted string

Solved!
Go to solution

Hello all,

I am working within pre-expressions trying to pull certain text from VI calls.  I had an issue where I couldn't correctly return values when using a variable.
Example: 
Step.TS.SData.ViCall.Parms["Remote IP"].ArgVal returning Locals.IP

Rather than 
Step.TS.SData.ViCall.Parms["Remote IP"].ArgVal returning 192.168.0.1

This was fixed thanks to a very kind user name CyGa.  He told me to user the evaluate function.  So now most of my code works.  However, I am having another road block that I have been scratching my head at for more than a few hours now.

When I try to pull information from an array input of a VI, I get an unformatted string of numbers
Example:
Str(Evaluate(Step.TS.SData.ViCall.Parms["TxData"].ArgVal)) Returns 225
Rather than
Str(Evaluate(Step.TS.SData.ViCall.Parms["TxData"].ArgVal)) Returning {0x2, 0x25}  (It used to return this when using just Step.TS.SData.ViCall.Parms["TxData"].ArgVal, but only when not using a variable as an input)

Does anyone know of a way to get test stand to return a formatted string like the second string of the second example?  Is there a way to convert an array of Numbers into a single formatted string?  Or do I need to do some form of inline loop to parse out what I expect the input bytes to be?

 

I would like the post expression I am creating to execute quickly so it doesn't cause timing issues with my tests.  If that is not possible, it is ok because only certain tests have timing issues and those can be worked around with a different sequence call.  I am sorry if I am asking for the moon, I honestly don't know what test stand is capable of.

 

Thanks,

Brady James

0 Kudos
Message 1 of 4
(4,073 Views)

Try this:

Str(Step.TS.SData.ViCall.Parms["TxData"].ArgVal, "%g, ")

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 4
(4,054 Views)
Solution
Accepted by topic author BradyJames

Forgot the Evaluate:

 

Str(Evaluate(Step.TS.SData.ViCall.Parms["TxData"].ArgVal), "%g, ")

 

New line between numbers:

Str(Evaluate(Step.TS.SData.ViCall.Parms["TxData"].ArgVal), "%g\n")

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 3 of 4
(4,053 Views)

Thank you very much!  My team and I were planning on using a very complicated recursive logic in line for loop to do this.  But this is much easier! Thank you very much!

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