DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIAdem Object Required issue

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

0 Kudos
Message 1 of 3
(304 Views)

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.

DIAdem experience since 1996

Turn-key applications - Remote and on-site trainings - On-the-job training

| müller+krahmer GmbH | Koenitzer Straße 14, 07338 Kaulsdorf / Germany |
| Phone: +49 36733 / 2328 - 6 | Mobile: +49 160 / 287 7294 |
| Email: mueller@mueller-krahmer.de | Web: www.mueller-krahmer.de |
Message 2 of 3
(262 Views)

Aaha, thanks, after changing the name of the variable, everything worked fine!

/Mikael

 

0 Kudos
Message 3 of 3
(254 Views)