07-17-2013 04:13 AM
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
Solved! Go to Solution.
07-17-2013 06:22 AM
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.
07-17-2013 06:27 AM
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
07-17-2013 06:45 AM
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.
Where did you expect this constant to be documented?