NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Hex to Decimal For Comparison

I'm running TestStand 3.0 using Win2K on an 8186 controller.  I'm reading a string of hex characters.  We pass these characters into a string variable.  I want to take the string, convert to hex and convert this hex to decimal so that I can do a numeric comparison.  Example, a "2A" comes back as a string.  I want to find out if its less than 11 in decimal.  Will TestStand allow me to do comparisons in hex and if not, how do I make the comparison.  My assumption was that I have to convert everything into decimal to do the comparison. 
 
Tony
0 Kudos
Message 1 of 3
(9,365 Views)
Tony,

Use the Val() expression in TestStand.  For example, Locals.X is a string, Locals.Y is a number.

Locals.X = "2A",
Locals.Y = Val("0x" + Locals.X)


At this point, Locals.Y is now 42.  You can choose to display this as 2A or 42, depending on your formatting options.  In any case, it represents the same number- the integer 42.
Message 2 of 3
(9,352 Views)

This is exactly what I was looking for.  Thanks for the assistance.

Tony

0 Kudos
Message 3 of 3
(9,344 Views)