Page 1 of 1

VBScript: CAN signals with the same name

Posted: Mon 18. Sep 2017, 14:36
by User41
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.

Re: VBScript: CAN signals with the same name

Posted: Tue 19. Sep 2017, 09:53
by K.Wolf
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")

Re: VBScript: CAN signals with the same name

Posted: Wed 20. Sep 2017, 12:01
by User41
It was, actually, very easy.
Thanks for the quick answer K.Wolf.