09-30-2025 01:52 AM
Hello,
I have a String "\$Bis,1,20240130,4096,PS,1#\$Prd,Z189055,012345678,00.00,0,BCH,20240130#\$Nam,AV4I PSM-HPLNA Q4#\$EndBis,A8,E0#"
I want to convert it to Hex,
Output should be, "244269732C312C323032343031332C343039362C50532C3123245072642C5A3138393035352C3031323334353637382C30302E30302C302C4243482C323032343031333023244E616D2C415634492050534D2D48504C4E412051342324456E644269732C41382C453023"
I have try to achive this uisng For loop, But I did not get answer.
Please help if you have any idea about that
Solved! Go to Solution.
09-30-2025 02:14 AM
TestStand is not exactly what I'd call a programming language, so it has some limitations... what are the reasons against implementing this conversion in a code module?
09-30-2025 02:26 AM
That I really did not understsand. I have try to to with several expession but did not work.
Do you have any idea how can I do this, some new method or any idea?
09-30-2025 03:53 AM
What you are trying to achieve could be done more conveniently using LabVIEW/.net/ Python.
This code can be called from TestStand.
09-30-2025 09:44 AM - edited 09-30-2025 12:44 PM
@Rshah31 wrote:
I have try to achive this uisng For loop, But I did not get answer.
A for loop is a programming structure that does not directly operate on data. Show us what you tried.
(You could have said you tried a screwdriver and we still would not know what you did!).
ASCII and HEX are both very vague terms and it is not really obvious what you are looking for.
ASCII is an ancient convention that assigns 7-bit patterns to readable or control characters.
HEX is just a formatting convention for binary data, reducing four adjacent bits to an ASCII character 1..F.
So what exactly do you have and what do you want. Maybe take a step back and explain your use case. For example your output is at least missing the "\" (i.e. all "\$ are reduced to "$"). Does "\" have a special meaning?
10-07-2025 04:04 AM - edited 10-07-2025 04:06 AM
Like everyone else said, I would use NI carefully when converting data like this. But it is possible, even though TestStand is not meant for these things. Basic steps inside a for loop:
1) Get the full length of your input string - Len(Locals.InputString) and create a for loop
2) Get one char with Mid function e.g. Locals.OneChar = Mid(Locals.InputString, Locals.LoopVariable, 1)
3) Inside the loop, convert each char to a number with Asc() function
4) Add the received number as a hex string to your output string buffer e.g. Locals.OutputString += Str(Locals.OneChar, "%02X")
Input: \$Bis,1,20240130,4096,PS,1#\$Prd,Z189055,012345678,00.00,0,BCH,20240130#\$Nam,AV4I PSM-HPLNA Q4#\$EndBis,A8,E0#
Output: 5C244269732C312C32303234303133302C343039362C50532C31235C245072642C5A3138393035352C3031323334353637382C30302E30302C302C4243482C3230323430313330235C244E616D2C415634492050534D2D48504C4E41205134235C24456E644269732C41382C453023
It seems your provided output string disregards the "\" symbol, so you should do something about that as well
10-07-2025 07:53 AM
Thank you for the reply,
It works---