How do i access individual symbols in a Macro?

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
OrangeFlavor
Posts: 4
Joined: Wed 6. Nov 2019, 09:13

How do i access individual symbols in a Macro?

Post by OrangeFlavor » Wed 6. Nov 2019, 09:16

I follow the document of "HELP" and execute the script bellow, but i got an error: Object not support this property or method
Thanks a lot for your reply.

Code: Select all

Sub SymbolsManagerExample()
   Dim objSymbols, str
   For Each objSymbols In SymbolsManager
      ' Access objSymbols here.
      ' For example:
      str = str & objSymbols.Document.FullName
   Next
   MsgBox str
End Sub

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: VBS For Each SymbolsManager

Post by M.Heidemann » Wed 6. Nov 2019, 11:25

Hello,

I would need to have more information to help you:

Which version of PCAN-Explorer are you using?

Did you use the symbol-manager to load this macro?

what's the file extension or your macro-file?

In wich line does this error occur? (This should be included in the errror message)

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

OrangeFlavor
Posts: 4
Joined: Wed 6. Nov 2019, 09:13

Re: VBS For Each SymbolsManager

Post by OrangeFlavor » Wed 6. Nov 2019, 12:04

Sorry for lacking issue description
M.Heidemann wrote:Which version of PCAN-Explorer are you using?
A: PCAN-Explorer 5
M.Heidemann wrote:Did you use the symbol-manager to load this macro?
A: I am a newer to use PE5 via Macro, I do not know where i should start.
The purpose of my learning this way is watch a RX msg then return a TX msg according to the receive signals value.
M.Heidemann wrote:what's the file extension or your macro-file?
A: *.pem
M.Heidemann wrote:In wich line does this error occur? (This should be included in the errror message)
A: error in line: For Each objSymbols In SymbolsManager
Last edited by K.Wagner on Wed 6. Nov 2019, 12:46, edited 1 time in total.
Reason: Quote formatting for better reading

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: VBS For Each SymbolsManager

Post by M.Heidemann » Wed 6. Nov 2019, 12:33

Could you send us a email with your License# and your PCAN-Explorer 5 version-information to our support email adress?

You can check the exact Version by clicking "Help" in the menubar and select "About PCAN-Explorer", this will show you a window with your exact PCAN-Explorer Version.
Also you can see your License-ID by clicking the "License Information" button on the same window.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

OrangeFlavor
Posts: 4
Joined: Wed 6. Nov 2019, 09:13

Re: VBS For Each SymbolsManager

Post by OrangeFlavor » Wed 6. Nov 2019, 12:41

OK, i wil send a mail with my software info to you.
And another question:
How can i send a message using macro if no Multiplexers in my symbols file, that is i not add multiplexer in my symbols file. The folder/file tree in symbol Editor is Symbols --> symbol--> variable

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: VBS For Each SymbolsManager

Post by M.Heidemann » Thu 7. Nov 2019, 15:00

Did you send us an email? We have not received one yet.

There are two ways to do this, either with a standard macro or with a vbs-macro.

It is important to know, that there is a default multiplexer that does act as a container for variables. This Multiplexer has the name "Empty".

Also make sure the symbol file is loaded in the connection you want to use.


Standard Macro

Here an example from the PCAN-Explorer 5 Help-File:
Syntax
Send Bus Symbol Multiplexer DataBytes

Code: Select all

// Symbol2 has no Multiplexer
Send 1 Symbol2 <Empty> AAh BBh
<Empty> is the default-multiplexer.

If your Symbol-File does not have any multiplexer you still have to refer <Empty>


VBS Macro

To make this easier to understand please take a look at the PCAN-Explorer 5 help and take a look at the diagram you can find in:

Automating Tasks in PCAN-Explorer -> PCAN-Explorer Objects -> Diagram of the Object Model

Let's take this Symbol-File as an starting point:

Code: Select all

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

{SENDRECEIVE}

[MySymbol]
ID=000h
DLC=1
Var=Var1 unsigned 0,1
Var=Var2 unsigned 0,1
Now our vbs-example looks like this:

Code: Select all

Sub SendSymbolExample()
   Dim sym, msg
   Set sym = SymbolsManager("DefaultMultiplexerSymbol").Item("MySymbol")
   Set msg = sym.DefaultMultiplexer.Send(1, peSendWait)
   msg.VariableValue("Var1") = 123
   msg.VariableValue("Var2") = 4.56
   msg.Write 0
End Sub
Set sym = SymbolsManager("DefaultMultiplexerSymbol")
This is the Title-Property of your Symbol-File,
.Item("MySymbol")
This is the name of your symbol,
Set msg = sym.DefaultMultiplexer.Send(1, peSendWait)
you can refer to the default multiplexer like shown above,
msg.VariableValue("Var1") = 123
msg.VariableValue("Var2") = 4.56
here you refer to your variables contained within your symbol file.


Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

OrangeFlavor
Posts: 4
Joined: Wed 6. Nov 2019, 09:13

Re: VBS For Each SymbolsManager

Post by OrangeFlavor » Fri 8. Nov 2019, 06:25

Great, Thanks a lot. This solve my question.

Post Reply