DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

converting decimal to hex in script for viewing in table

I know I must be missing something easy here.  I'm trying to output my data in hexadecimal form into a channel table.   Right now when I view my data, it's in decimal form.  An example of my code is below.  It's not the whole code, but what you see pretty much repeats itself. I keep getting errors saying "Object doesn't support this property or method".  I've had this error before when trying to perform the "FormatPercent" function. I've yet to figure that one out either.  Anyway, any help you guys can give will be greatly appreciated. 
 
 
Option Explicit

Sub ReadStore(File)
 Dim Channel(76), i, Block, Group, ChannelPH(10), BlockWidth
 
    BlockWidth = 154
    File.Formatter.ByteOrder = eLittleEndian
    Set Block = File.GetBinaryBlock() 'Create Block.  This is a binary file format.
    Set Group = Root.ChannelGroups.Add(File.Info.FileName) 'Create a channel group in USI
   
 
    Set Channel(0) = Group.Channels.AddImplicitChannel("Index", 0, 1, 2, eR64)
 
    Set Channel(1) = Block.Channels.Add("FPGA_Rev", eByte) 'Reports the current revision number of FPGA Code.
 
    Set Channel(2) = Block.Channels.Add("Mechanical_Angle", eU16) '2 bytes of data. Byte 2 is MSB Byte 1 is LSB. might have to switch big/little endian
          Channel(2).Factor = 0.000244140625 ' 1/4096 per Bit
 
    Set Channel(3) = Block.Channels.Add("Unused1", eByte)  'byte not used. Can be ignored
 
    Set Channel(4) = Block.Channels.Add("Hall_Codes", eByte)
          Channel(4).Formatter.Bitmask = "0x07" 'Hall codes are bits 0-2 of the Byte.  Bits 3-7 are ignored.
 
    Set Channel(5) = Block.Channels.Add("Unused2", eByte)  'byte not used. Can be ignored
 
    Set Channel(6) = Block.Channels.Add("Block Counter", eU16)  '16 bit counter. count will increase with each block that is read.
       
    Set Channel(7) = Block.Channels.Add("Unused4", eByte)  'byte not used. Can be ignored
 
FOR i = 1 TO UBound(Channel)
    Call Group.Channels.AddDirectAccessChannel(Channel(i))
  NEXT ' i
  Channel(0).Size = Channel(1).Size

End Sub
0 Kudos
Message 1 of 4
(4,254 Views)

Hi mjletts,

I couple of clarifications. Where exactly are you getting the error. I copied your code and ran in it DIAdem 9.1 and I didn't quite get the error you were mentioning. What is the version of DIAdem you're using. If I understand you correctly, you have a hexadecimal data file and you're trying to read this file into data portal. Or are you trying to read a ascii file that contains decimal data and you're trying to convert that to hexadecimal before you bring into the data portal. I apologize if I am going on the wrong track here, but I wanted to make sure I understand the problem before I give you a suggestion.

I hope to hear from you

SijinK

National Instruments

0 Kudos
Message 2 of 4
(4,218 Views)

Hi mjletts,

From your code, I take it that you're reading in a binary file using a data plugin. Once you have read your data file into DIAdem then you can change the formatting of the channel when you display it.

Once your drag your channels in DIAdem VIEW, then the following code will change the formatting to hexadecimal.

For Each Channel in View.Sheets(1).Areas(1).DisplayObj.Columns
 Channel.Format="$"
Next

I hope this helps

SijinK

National Instruments

0 Kudos
Message 3 of 4
(4,206 Views)
SijinK,
    Hey thanks for helping out.  Your suggestion works very well.  Sorry it took me so long to try it out, i was on vacation last week.  Thanks again!!!
 
Matt
0 Kudos
Message 4 of 4
(4,188 Views)