DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

convert hex text to number?

Hi all,

I'm trying to import an ASCII file to DIADEM (9.1), in which 1 Column is a text representation of a Hex number:

00010010
000A000F
and so on.

How do I import this column as a number? If I just choose "Numeric" in the Import Assistant, I get "no value" in the rows with the higher Hex numbers (ABCDEF).

Or can I import the column as text and then convert it somehow (without using LabVIEW)?

Thanks for your help!


Regards

Stefan
0 Kudos
Message 1 of 4
(12,709 Views)
Hi StGl,

If all you want is to see the hex values in DIAdem, even display them in a table column, then you can import them as string channels and leave them that way. But if you want to cast those hex strings to numeric values, you're going to have to use VBScript with the following syntax:

HexString = "100A000F"
HexInteger = CLng("&h" & HexString)

Now you can do this in a VBScript that reads the strings from the file and imports the numeric values into DIAdem, or you can first import the hex strings as DIAdem string channels and then run a VBScript to create a new channel with the hex integer values. Note that no more than 8 hex "digits" can be contained in a long integer.

If you happen to have DIAdem 9.1, you could build a VBScript DataPlugin to do the importing and hex conversion using the above syntax, so all the user has to do is drag and drop the file from the NAVIGATOR into the Data Portal.

Regards,
Brad Turpin
DIAdem Product Engineer
National Instruments
Message 2 of 4
(12,703 Views)
Thanks,

works perfectly.

Regards,

Stefan
0 Kudos
Message 3 of 4
(12,688 Views)

Sorry, I discovered why I had problems using this on Channels: I was trying to redirect the function to the same channel, e.g.

CH(1) = CLNG("&H" & CH(1))

and that does not work as Ch1 is text and cannot take the decimals.

Message 4 of 4
(9,687 Views)