10-12-2024 04:41 AM
Hi, I have a script part that works fine by it self and it is adding a "Customer Properties" row in a data file in the Data portal as below.
I'm using DIAdem 2021.
Set myChannelGroup = Data.Root.ChannelGroups(1)
myChannelGroup.Activate
Call myChannelGroup.Properties.Add("Info", Variable)
However, as soon as I add a script part before this section I get the Error message "Object Required" regarding the row "Set myChannelGroup = Data.Root.ChannelGroups(1)".
Is there any way to activate the object or to somehow pass this?
The script part that I add before this "Properties.Add" is opening another CSV-file and populates an array with the data from some of the rows and columns. It is from this array I want to add the information to the Properties...
****************
Dim fso, file, line, columns, filePath, Row01Col01
Dim data(6, 20) ' Array to store data for 11 rows and 10 columns (0-based index)
Dim rowCount, colCount
Call FileNameGet("ANY", "FileRead", DataReadPath, "*.DAT")
Call DataFileLoad(FileDlgFileName)
filePath = "C:\Temp\Test_Data.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile(filePath, 1) ' 1 = ForReading
rowCount = 0
Do While Not file.AtEndOfStream And rowCount < 7
line = file.ReadLine()
columns = Split(line, ";")
' Loop through the first 20 columns (or less if the row has fewer columns)
For colCount = 0 To 19
If colCount < UBound(columns) + 1 Then
data(rowCount, colCount) = columns(colCount)
Else
data(rowCount, colCount) = ""
End If
Next
rowCount = rowCount + 1
Loop
file.Close
Set file = Nothing
Set fso = Nothing
Row01Col01 = data(0, 0)
Set myChannelGroup = Data.Root.ChannelGroups(1)
myChannelGroup.Activate
Call myChannelGroup.Properties.Add("Info", Row01Col01)
**************************
Thankful for any help!
/Mikael
10-18-2024 04:37 AM
The cause of the error is the defintion of a variable called "data":
Dim data(6, 20)
Data is the object used by DIAdem to access internal data. So use a different name for this variable.
10-18-2024 06:13 AM
Aaha, thanks, after changing the name of the variable, everything worked fine!
/Mikael