VBScript: CAN signals with the same name

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
User41
Posts: 2
Joined: Mon 18. Sep 2017, 14:14

VBScript: CAN signals with the same name

Post by User41 » Mon 18. Sep 2017, 14:36

Hello.
I'm writing a very siple VBScript that given the value of a CAN signal copies this value into another signal.
Normally, whit two signals with different names I do as follows:

Code: Select all

Sub Example()
dim sig1, sig2
set sig1=Signals("VAR1")
set sig2=Signals("VAR2")

While true
          sig1.Value = sig2.Value
          wait 10
Wend
End Sub
VAR1 and VAR2 are defined in the .sym file.

Now I'm facing the problem that the 2 variables have the same name, what differs is the multiplexer. Below there is an example of the symbol file:

Code: Select all

FormatVersion=5.0 // Do not edit this line!
Title="EXAMPLE"

{SENDRECEIVE}

[MESSAGE]
ID=001h
DLC=8
Mux=MUL1 0,2 1 
Var=Var1 unsigned 8,8

[MESSAGE]
DLC=8
Mux=MUL2 0,2 2 
Var=Var1 unsigned 8,8
I cannot simply use the Signals collection anymore. How can I use the multiplexer too? I've tried this:

Code: Select all

set sig1=Multiplexer("MUL1").Signals("VAR1") 
but this does not work.

Can someone gime me a hint on how to solve this?

Thanks.

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: VBScript: CAN signals with the same name

Post by K.Wolf » Tue 19. Sep 2017, 09:53

You can use the qualified name of the signal to find the correct signal in the collection:

Code: Select all

Set sig = Signals("MESSAGE.MUL1.Var1")
and

Code: Select all

Set sig = Signals("MESSAGE.MUL2.Var1")

User41
Posts: 2
Joined: Mon 18. Sep 2017, 14:14

Re: VBScript: CAN signals with the same name

Post by User41 » Wed 20. Sep 2017, 12:01

It was, actually, very easy.
Thanks for the quick answer K.Wolf.

Post Reply