NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting from HEX to Decimal

Solved!
Go to solution

Hello folks

I am currently stuck with a task, where I must convert a HEX output to a decimal value.

In example I receive this string from my function, which I save as a local variable: 

Andedam_0-1598252156604.png locals.SoftwareVersion = step.result.string


I now need to convert this hex value to the decimal value 0.05.26 with DOTS, and print it to the report. What is the procedure? 

Thank you in advance!

0 Kudos
Message 1 of 5
(3,050 Views)

I don't think you can do this change in a single step because most of the TestStand functions don't work with arrays. What you can do is:

1-Use the function Split() to separate the three numbers in an array of strings

2-Use a For Each structure to go through each string, change it to decimal and concatenate the result with dots between them

3-Remove the last unneeded dot.

0 Kudos
Message 2 of 5
(3,024 Views)

Hello


I do not seem to be able to get this working. 

What I did;

Andedam_0-1598267599205.png

Please elaborate further, thank you!

0 Kudos
Message 3 of 5
(3,017 Views)
Solution
Accepted by topic author Andedam

Here you have an example.

Message 4 of 5
(3,011 Views)

Hello once again

Thank you very much for that good example! Helped me out a lot! Huge kudos to you!

However, when running it with my function, it would yield; "00.05.26" and only run with #noValidation

I therefore also removed the first character as so;

#NoValidation,
Locals.FW_PSKey=Left(Locals.FW_PSKey,Len(Locals.FW_PSKey)-1),
Locals.FW_PSKey=Right(Locals.FW_PSKey,Len(Locals.FW_PSKey)-1),

For this it yields "0.05.26" as I want. 

Thank you very much, have a splendid day kind sir!!

0 Kudos
Message 5 of 5
(3,004 Views)