Manipulating data via VBScript

I am trying to use VBScript to manipulate data to and from .TXT files

I can successfully save information to a .TXT file, in a '$TagName; TagValue' kind of format.

I seem to be able to read that information back into variables, but I am struggling to use this information.

-----

Dim fso, File, FileValue, tagName, tagValue, strLine, arrItems, objFile, objTag

FileValue = $Seq_Name
$Z = 1
Set fso = CreateObject("Scripting.FileSystemObject")
$Z = 2
File = (FileValue & ".txt")
$Z = 3
If fso.FileExists(File) Then
$Z = 4
$Y = File
$Z = 5
objFile = fso.OpenTextFile(File,1)
$Z = 6
Do
$Z = 7
strLine = objFile.ReadLine
arrItems = Split(strLine, ";", -1, 1)
tagName = CStr(arrItems(0))
tagValue = CStr(arrItems(1))
$Z = 8
Set objTag = TagName
$Z = 9
objTag.Value = tagValue
$Z = 10
objTag.Write
$Z = 11
Loop Until objFile.AtEndOfStream
$Z = 12
End If
objFile.Close

-----

$Z and $Y are my trace tags.  The script gets to '$Z = 8' then stops.  This is where i need to identify the contents of TagName as a tag, and then copy information into it.

Any pointers would be appreciated.

Parents
  • Bob, take a look at the Edge Built in Scripting function FileReadFields()

    The function FileReadFields reads values contained in the fields of a CSV file, and then it writes those values to a series of project tags or array elements

  • Hello Scott.

    Looking at FileReadFields in the help.

    Assuming I can use the command in VB, and not as a 'built-in language' function (I would run out of command lines). It seems I need to read each value individually and specify each tag for the destination (I am reading hundreds of values) 

    The other difficulty I see is that some of these values are of variable length (being strings) so the offset for specific data would be impossible to calculate.

    Ideally I need to assign the first value of each line as the destination tag for the second value in a program loop as shown above, until it runs out of lines to read.

Reply
  • Hello Scott.

    Looking at FileReadFields in the help.

    Assuming I can use the command in VB, and not as a 'built-in language' function (I would run out of command lines). It seems I need to read each value individually and specify each tag for the destination (I am reading hundreds of values) 

    The other difficulty I see is that some of these values are of variable length (being strings) so the offset for specific data would be impossible to calculate.

    Ideally I need to assign the first value of each line as the destination tag for the second value in a program loop as shown above, until it runs out of lines to read.

Children
No Data