ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Logfilewrite

Solved!
Go to solution

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.

 

0 Kudos
Message 1 of 3
(2,782 Views)
Solution
Accepted by topic author Simon_Aldworth

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

0 Kudos
Message 2 of 3
(2,748 Views)

Oops, should have spotted that. Thanks Brad.

0 Kudos
Message 3 of 3
(2,710 Views)