01-15-2019 11:10 AM
Hello,
I hope the title isn't too confusing, but I have data in the format shown below:
Chn_1 1 2 3 4 5
Chn_2 a b c d e
Chn_3 1.1 2.1 3.1 4.1 5.1
Chn_4 1 2 3 4 5
I want to be able to use the GetCellBlockor or GetStringBlock with this data, but it seems to require that the channel names are going across the columns instead of down the rows.
Does anyone have a clean way grab these channel and add them with the correct data type to the data portal?
Solved! Go to Solution.
01-16-2019 12:59 PM
Hello Kevin_McG,
Would you mind posting how you are attempting to use these calls? I want to see if I can recreate something over here and mess around with the calls.
Best,
Danielle
01-17-2019 08:38 AM
There is no way to use the stringblock directly but you plugin code could look like this just using the build in parser to help.
Data
Chn_1 1 2 3 4 5 Chn_2 a b c d e Chn_3 1.1 2.1 3.1 4.1 5.1 Chn_4 1 2 3 4 5
Plugin Code
Option Explicit Sub ReadStore(File) File.Formatter.Delimiters = " " File.Formatter.LineFeeds = vbNewLine file.Formatter.TrimCharacters = " " ' trim the spaces File.Formatter.DecimalPoint = "." Dim ChannelGroup : Set ChannelGroup = Root.ChannelGroups.Add(File.Info.FileName) do dim channelName : channelName = File.GetNextStringValue(eString) if isEmpty(channelName) then RaiseError ' This file has a different format end if ' use the first value to determine the datatype of the channel dim channelValue : channelValue = File.GetNextStringValue(eString) dim channelDataType : channelDataType = eR64 if(0 = file.Formatter.ParseString(channelValue,channelDataType) AND "" <> file.Formatter.ParseString(channelValue, eString)) then channelDataType = eString ' value is not numeric so we load it as string end if dim chO : set chO = ChannelGroup.Channels.Add(channelName,channelDataType) dim i : i = 1 cho.Values(i) = file.Formatter.ParseString(channelValue,channelDataType) ' ' add the remaining values by looping till the line is eaten channelValue = File.GetNextStringValue(channelDataType) do while NOT VBEMPTY = VarType(channelValue) i = i + 1 cho.Values(i) = channelValue channelValue = File.GetNextStringValue(channelDataType) Loop Loop until NOT File.SkipLine End Sub