08-22-2011 08:35 AM
Good day to NI experts,
I would like to ask for help regarding VBAI's Calculator step. Is there any way I could convert Hexadecimal String in to ASCII character? For example 25(Hex) to %(ASCII) or if not in Calculator any other methods? I'll have to send the data through TCP/IP afterward.
Thank you very much,
Andrei K.
Solved! Go to Solution.
08-22-2011 09:15 AM
Here's a sample of what you could do. There are also other formaters for the "Format to String" like %08x will pad the resulting string with zeros if the hex value doesn't take up 8 characters.
Hope this helps,
Brad
08-22-2011 08:40 PM
Sir,
Thank you very much for the response but I can't seem to have an ASCII output as required. In my program, I computed for Number of strings and gave me 37Decimal. I converted it to Hex String and gave me 25String. I then converted 25String to Hex and gave me 25Hex. Now, 25Hex should be converted into ASCII. It's ASCII value should have been "%" (percent symbol) and not "19".
What has transpired in the program is that the "Format Into String" command has converted the 25 value into 19. When you convert 25Dec to Hex, the result would be 19Hx therefore, it didn't convert Hex into ASCII. Still hopefull that there would be a way to get an ASCII result.
Thank you very much,
Andrei k.
Philippines
08-22-2011 08:42 PM
Hex to ASCII image
08-22-2011 08:42 PM
Hex to ASCII image
08-22-2011 09:40 PM
Now I understand what you want. You can actually accomplish this from the TCP step. First you will need to get the length of the string in a numeric like you did in the Calculator step, but then you can send this numeric as a hex ascii string in the TCP step. To do this, have the result of the calculator return the length of the string as a numeric. In the TCP step, add a Write command and Insert a result. Select the numeric output from the Calculator step and choose U8 for the data format. You can use the Normal Display/Hex Display to see the data that will be sent and when viewing normal display, you can see it is a value of '%' when the length is 37. See the attached screenshot to see how I did this.
Hope this helps,
Brad
08-23-2011 07:12 AM
Hi Mr. Brad,
Wow! That really is the solution. I appreciate and thank you very much for the great help!!!
Sincerely,
Andrei K.