DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Plugin: assign channel values from variant array

Solved!
Go to solution

Hello, again

 

I am still fighting with a DataPlugin consisting of tab separated data

 

When I read a line via

          sMyLine =  file.getnextline

 

and try to extract the values with

          aMyValues = split(sMyLine, vbTab etc)

 

the array returned is of type Variant.

 

Now I try to assign values from this array to different channels, e.g.

 

for i=1 to Ubound(aMyValues)

      root..channelgroups(j).channels(i).values(k) = aMyValues(i)

next

 

This results in an error message "This channel was generated with Type e64, values to be filled in must not be of type VT_BSTR" or whatever the english translation would be.

 

So I have to transform the variant array to a R64-array. However cdbl(aMyValues(1)) will not work.

 

Cumbersome workaround:

When reading data with

            root..channelgroups(1).channels(1).values(1) =file.GetNextStringValue(e64)

the value is of appropriate type. But this results in many single read operations.

Is there a way to read in one line and append the values to channels? File.GetStringBlock in the examples is mostly used with DirectAccessChannels.Add. But I do not want toadd new channels, but rather append to existing ones.

 

Thank you for your support.

Michael

 

 

0 Kudos
Message 1 of 4
(6,073 Views)
Solution
Accepted by topic author nimic

Hi,

 

I think there are several ways to achieve your goal.

If you want to assign the values of your variant array to a numeric channel, you can use the File.Formatter.ParseString() method. Please make sure the formatters for your numeric values are set as needed, e.g. File.Formatter.DecimalPoint, etc.

File.Formatter.DecimalPoint = ","
...
for i=1 to Ubound(aMyValues)
      root..channelgroups(j).channels(i).values(k) = File.Formatter.ParseString(aMyValues(i), eR64)
next

 

The preferable way is to use the StringBlock object. If you do not want to create a new channel for each DirectAccessChannel, you can use ProcessedChannel to append multiple DirectAccessChannels, e.g.

Dim processedChn : Set processedChn = channelGroup.Channels.AddProcessedChannel("ChannelName", eR64, eConcatProcessor)
...
processedChn.Channels.Add(DirectAccessChannel)

 Hope this helps.

Message 2 of 4
(6,066 Views)

Thank you for your hint - it points the right direction, particularly as my next issue is to convert a variant string "1.1.2012 01:02:03" into a eTime value...

 

Humhumhum: eConcatProcessor - I have the feeling that this bunch of eSomething constants is highly undocumented.

 

Michael

0 Kudos
Message 3 of 4
(6,062 Views)

These constants can not be found using the index of the help. However, they are documented in the help for the functions where they are accepted, e.g. AddProcessedChannel. In addition, the syntax highlighting of DIAdem pops up a short explanation for each parameter of a function.

Syntax.PNG

Where did you expect this constant to be documented?

Message 4 of 4
(6,057 Views)