02-05-2018 04:04 AM
Hello everyone,
I have a DIAdem VBS script which is working fine. It consists on a file parser which will split a channel into a group of channels. The channels to be splited are like bit arrays, so that's why we want to split it, to analyze each bit individually .
The problem is that the file to be parsed is normally very long (20000 - 5000 lines) and my code to iterate thorugh lines is like this:
Do While line <> "EOF" I = I + 1 line = FR(PathOfTheFile,I)
The result is that it may take about an hour to split a bit-array variable, which is way too much.
My question is... Is there other way to iterate through lines in DIAdem VBScript?
If something is not clear, don't hesitate to ask and thank you all very much in advance,
Martin
02-05-2018 07:51 AM - edited 02-05-2018 07:53 AM
Typical... As soon as I ask, I find the answer... This is the best method I found to parse a text. It works wayy faster than the method I explained before.
http://zone.ni.com/reference/en-XX/help/370858L-01/scripting/methods/scripting_method_readline_itext...
I adapted the next function for my purpose and it worked like charm!
Function ReadFile(sFile) Const ForReading = 1 Dim fso, oMyFile Set fso = CreateObject("Scripting.FileSystemObject") Set oMyFile = fso.OpenTextFile(sFile, ForReading, False) ReadFile = oMyFile.ReadAll oMyFile.Close End Function
I hope someone with the same issue will find this useful 😄