04-29-2013 08:33 AM
Most of the examples for DataPlugin programming use channel names in separate lines, like the following example:
Channel
Name: Time
Type: Time
Channel
Name: XShift
Type: R64
Channel
Name: YShift
Type: R64
Most of my data sets have channel names and / or units in one tab-separated line such as
"Dehnung" "Standardkraft" "Sensor" "Zyklusnummer" "PWM"
"mm" "N" "V" "" "%"
Is there a more efficient way of adding channels named and equipped with units as per these lines than cycling through some index variable? As my channel number, naming etc. vary frequently, I'd be looking for a more flexible solution, avoiding fixed array sizes or hard-coded names.
I suppose
aMyChannelNames = split(File.GetNextStringValue(eString), vbTab)
aMyChannelUnits = split(File.GetNextStringValue(eString), vbTab)
for i = 0 to UBound(aMyChannelNames)
Set Channel = Block.Channels.Add(aMyChannelNames(i),eString)
channel.porperties("Unit")=aMyChannelUnits(i)
next
might do the job - but is this the most efficient way?
Thank you for assisting.
Michael
Solved! Go to Solution.
04-30-2013 05:59 AM
Hello Michael,
I don't see the real problem.
You read the header and split it into an array. This is the information how many channels you have. The array size ubound depends on the line you've red and isn't fix. Everything should be fine now.
You first read hte information and split it to arrays. Afterwards you use a loop to generate the channels and set the properties. I don't think there's a more efficient way to do this.
Kind Regards,
Philipp K.
AE | NI Germany
04-30-2013 07:39 PM
Hi Michael,
I prefer to use Split() in exactly the way you mentioned. You could also try File.GetNextStringValue() if you prefer, just don't forget to call File.SkipLine() or you won't ever move the file cursor to the next line, which File.GetNextLine() does automatically.
Brad Turpin
DIAdem Product Support Engineer
National Instruments