10-07-2021 09:58 AM
Hello,
For some unknown reason I am finding that I cannot write multiple items using LogFileWrite anymore. The following code is fine when writing the first four LogFileWrite lines, each with a single entry, but fails for all the multiple ones. Why is this?
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim myGp, i
Set myGp = Data.Root.ChannelGroups(1)
For i = 1 to myGp.Channels.Count
logfilewrite myGp
logfilewrite myGp.Channels.Count
logfilewrite i
logfilewrite myGp.Channels(i).Name
logfilewrite myGp & ", " & myGp.Channels.Count
logfilewrite myGp & ", " & myGp.Channels.Count & ", " & i
logfilewrite myGp & ", " & myGp.Channels.Count & ", " & i & ", " & myGp.Channels(i).Name
logfilewrite i & ", " & myGp.Channels(i).Name
logfilewrite myGp.Channels.Count & ", " & i
Next
Regards, Simon.
Solved! Go to Solution.
10-08-2021 04:50 PM
Hi Simon,
The issue you're running into here is that the LogFileWrite() command accepts only a string parameter. Your "myGp" variable is an object variable, and you can't print an object variable in VBScript (you can in python). You also can't concatenate a string to the end of an object variable. Any command where you have this will throw an error:
logfilewrite myGp &
Brad Turpin
Principal Technical Support Engineer
NI
10-11-2021 03:07 AM
Oops, should have spotted that. Thanks Brad.