From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

How to convert a string to hex in TestStand

Hi everyone, I think this is a fairly easy question to answer but I am newer to TestStand.

 

In one step I am pulling in the Serial Number of a Device (which is alpha and numeric characters) and storing it as a String Local called Local.SerialNumberString.  In the following step I need to convert this Local to a Hex value and store it as Locals.SerialNumberHex

 

Here is the data representation I need to take place:

 

Locals.SerialNumberString = ABC123456

 

and would like to know of a function that would convert to the following:

 

Locals.SerialNumberHex = 414243313233343536

 

How can this be done?

 

Thanks so much!

0 Kudos
Message 1 of 2
(8,202 Views)

It looks like what you are asking for is more than just converting to hex, it looks like you want to convert the characters in the string to their ascii value representation and then convert that to hex.

 

1) Use a for loop Locals.i = 0; Locals.i < Len(Locals.SerialNumberString); Locals.i++

2) Inside the loop do: Locals.SerialNumberHex += Str(Asc(Mid(Locals.SerialNumberString, Locals.i, 1)), "%.2x")

 

Hope this helps,

-Doug

Message 2 of 2
(8,193 Views)