UI with VBScript Macro or Strandard Macro

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
epignosi
Posts: 11
Joined: Thu 23. Feb 2023, 16:48

UI with VBScript Macro or Strandard Macro

Post by epignosi » Wed 17. Apr 2024, 10:26

Hello,

My last topic was closed (viewtopic.php?f=205&t=7592)
So I come back here.

I managed to do what I wanted using an .mcr script. It was only a macro which is sending data in loop with a delay between different frames.

But now I want to make something with button on .ipf like this :
Image

I manually put 2 data, for example data1 and data2, and If I press the button "SendParameters" the script will send different frame with data1 and data2
Imagine i've put 300 for data1 and 50 for data2 If I press the button the script will do :

Code: Select all

Send 1 02A43FF0h 8 11h 34h 00h 00h 00h 00h 00h A0h
Wait 300
Send 1 02A43FF0h 8 21h 10h 00h 00h 00h 00h 00h A2h
Wait 300
Send 1 02A43FF0h 8 11h 02h 00h 00h 00h 00h 01h 2Ch // (12C for 300 (data1 in hex))
Send 1 02A43FF0h 8 11h 02h 00h 00h 00h 00h 00h 32h // (32 for 50 (data2 in hex))
Could we imagine do something like this :

Code: Select all

If buttonSendParameters.Value is True
	Send 1 02A43FF0h 8 11h 34h 00h 00h 00h 00h 00h A0h
	Wait 300
	Send 1 02A43FF0h 8 21h 10h 00h 00h 00h 00h 00h A2h
	Wait 300
	Send 1 02A43FF0h 8 11h 02h 00h 00h 00h 00h 01h 2Ch // (12C for 300 (data1 in hex))
	Send 1 02A43FF0h 8 11h 02h 00h 00h 00h 00h 00h 32h // (32 for 50 (data2 in hex))
EndIf
NB : buttonSendParameters is VirtualVariable with Symbol v.5 assigned to .ipf button to detect when user press the button on UI.

Is something like this is can be done on mcr file or VBS macro ?

Best Regards

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

Re: UI with VBScript Macro or Strandard Macro

Post by M.Heidemann » Wed 17. Apr 2024, 10:40

Hello,

You can trigger a Macro by using the "Behavior" -> "Execute Command" parameter of your IP-element:
ExecuteCommand.png
ExecuteCommand.png (6.46 KiB) Viewed 1842 times
So you could check your condition inside a Macro and then trigger it when clicking the button,
You can use a label to mark the specific portion of the Macro you want to execute:
LabelsSTDMacro.png
LabelsSTDMacro.png (19.32 KiB) Viewed 1842 times
Please let me know if this works for your intended purpose.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

epignosi
Posts: 11
Joined: Thu 23. Feb 2023, 16:48

Re: UI with VBScript Macro or Strandard Macro

Post by epignosi » Wed 17. Apr 2024, 10:57

Can I use a .mcr which is running in loop
And execute another .mcr when button is pressed ?

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

Re: UI with VBScript Macro or Strandard Macro

Post by M.Heidemann » Wed 17. Apr 2024, 11:04

Hello,

this is out of the scope of what you can achieve with Macros.

You can break a loop by checking a signal and then execute another Macro
and return to the previous macro afterwards but running in parallel isn't possible.

Depending on the scope of your application i would also suggest to have a look
at the PCANBasic API. Wether its Standard or VBScript Macros, eventually you'll reach a point
where the whole application becomes next to impossible to support and if anything breaks:
The lack of proper debugging tools can be a major disadvantage.

Your application now is rather small but i rather give this suggestion now before alot of work
is put into the implementation in PCAN-Explorer 6.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

epignosi
Posts: 11
Joined: Thu 23. Feb 2023, 16:48

Re: UI with VBScript Macro or Strandard Macro

Post by epignosi » Fri 19. Apr 2024, 09:24

I don't need to make a huge application, I only need to send command frame and read values from the system I send command frame. I think PCAN Explorer 6 can do it.
I've got a little problem, and I don't know how I can solve it.

With this code, I got an "Error : Stack overflow!"

Code: Select all

FormatVersion=6.0

Call SendParameters

SendParameters:

					Send 1 02A43FF0h 8 11h 34h 00h 00h 00h 00h 00h A0h // set automatic voltage stabilization mode
					Wait 10
					Send 1 02A43FF0h 8 21h 10h 00h 00h 00h 00h 00h A2h // set grid off inverter mode
					Wait 10
					Send 1 02A43FF0h 8 11h 02h 00h 00h 00h 00h EAh 60h // EA60h = 60 000 for 60 000 mA
					Wait 10
					Send 1 02A43FF0h 8 11h 32h 00h 00h 00h 03h 0Dh 40h // 30D40h = 200 000 for 200 000 mV
					Wait 10
					Send 1 02A43FF0h 8 11h 10h 00h 00h 00h 00h 00h A0h // start module
					Wait 50
					Repeat
Screen of my error : Admin: External Links are prohibited, you can add attachments.

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

Re: UI with VBScript Macro or Strandard Macro

Post by M.Heidemann » Fri 19. Apr 2024, 09:40

Can you provide us with the picture again, this time using the attachment function of the forum?
We are dilligent about external links and will not open them.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

epignosi
Posts: 11
Joined: Thu 23. Feb 2023, 16:48

Re: UI with VBScript Macro or Strandard Macro

Post by epignosi » Fri 19. Apr 2024, 09:44

Oh yes, sorry.
Please found it in attachments

Best Regards,
Attachments
Capture d'écran 2024-04-19 092344.png
Capture d'écran 2024-04-19 092344.png (59.71 KiB) Viewed 1813 times

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

Re: UI with VBScript Macro or Strandard Macro

Post by M.Heidemann » Fri 19. Apr 2024, 10:29

Hi,

Can you please check the version of PCAN-Explorer 6 you are currently running?

You can do so via Help -> About Pcan-Explorer
Version.png
Version.png (10.69 KiB) Viewed 1811 times
version_2.png
version_2.png (93.09 KiB) Viewed 1811 times

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

epignosi
Posts: 11
Joined: Thu 23. Feb 2023, 16:48

Re: UI with VBScript Macro or Strandard Macro

Post by epignosi » Fri 19. Apr 2024, 10:59

I'm using same version of you, the : 6.7.0.2830

And I'm using a 125 Kpbs CAN BUS.

Best Regards,
Attachments
Capture d'écran 2024-04-19 105701.png
Capture d'écran 2024-04-19 105701.png (32.29 KiB) Viewed 1808 times

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

Re: UI with VBScript Macro or Strandard Macro

Post by M.Heidemann » Fri 19. Apr 2024, 11:03

Hello,

Can you reproduce this behavior, if you do not use a label and call?
You currently do not use it, as there is only this in your macro.

Please let us know!

Best Regards

Marv
---
Marvin Heidemann
PEAK-Support Team

Locked