DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

FormatPercent problems

I'm trying to us the FormatPercent function and it's giving me problems. Here's how i have it written:

Set Channel(16) = Block.Channels.Add("percent", eI16)
Channel(16) = FormatPercent(Channel(16)/219.49)

When i try to run the script, it gives me an error "Object doesn't support this property or method". What am I doing wrong??? Thanks for the help!!

Matt
0 Kudos
Message 1 of 4
(3,645 Views)
Hi Matt,

I actually think that you are receiving this error message because of the first line of code you are posting. I am wondering what "block" is in your script. Is it the name for another object since I cannot find it as a built in DIAdem object? Let me know if I am just overlooking it though or how you created this object. I am actually thinking that the best solution may be if you can post a small part of your script that will show me the setup of your object as well as the error. Then I can reproduce the issue here.

Thanks,
Caroline
National Instruments
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 2 of 4
(3,633 Views)
Here is a sample of my script and how i set things up:

Sub ReadStore(File)
Dim Channel(36), i, Block, Group, ChannelPH(10), BlockWidth


BlockWidth = 71
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.

'from here, i just set up Channels 1-36. One of these channels is "MyPercent" shown below

Set Channel(16) = Block.Channels.Add("MyPercent", eI16)
Channel(16) = FormatPercent(Channel(16)/219.49)

I hope this helps a little. Thanks for taking time to help!!
0 Kudos
Message 3 of 4
(3,627 Views)
Hi Matt,

After looking more into your code and researching a little more, I realized that FormatPercent() can only be used on scalar arguments. You seem to be trying to scale the whole channel with one line by passing the channel object which you cannot do. YOu will need to load the data in as a normal nummeric (fractional) channel and format the display once in DIAdem. There fore you will want to remove the FormatPercent() line from your code and then deal with the formatting once the data is loaded into DIAdem.

However, if you are using DirectAccessChannels you can use a factor and offset. For example:

Dim MyChn : Set MyChn = MyChnGrp.Channels.AddDirectAccessChannel(Channel)
MyChn.Factor = 1/2.1949
MyChn.Offset = 0

Yet, the formatting such as "d.dd%" will still need to be handled within DIAdem.

Thanks,
Caroline
National Instruments
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 4 of 4
(3,611 Views)