PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Event handling  (Read 1041 times)

Gilles

  • Silver Member
  • ***
  • Posts: 27
    • View Profile
Event handling
« on: January 13, 2021, 08:42:25 AM »
In the online Pxplus documentation at the bottom of "ON PROCESS EVENT" there is a link for Event Handling Interface wich does not work.
The error refers to wiki.pvxplus.com.
Where can we found documentation for this interface?

Stéphane Devouard

  • Diamond Member
  • *****
  • Posts: 122
  • PxPlus guru with skills in PHP, JS, C#, Java
    • View Profile
    • Stéphane's Web Resume
Re: Event handling
« Reply #1 on: January 15, 2021, 03:35:21 AM »
Gilles


You can find some additional information here :
https://manual.pvxplus.com/PXPLUS/directives/processevents.htm


Basically :
- You define an event to be generated using the PROCESS EVENT directive, assigning a name and a list of arguments that will be passed to the event handler logic
- You assign an event handler using the ON PROCESS EVENT, specifying the name of the event to be handled and the name of a handler routine to CALL or PERFORM (there is an enhancement planned to be able to use also an object's method but it's not yet available)
- Whenever the event is triggered (the PROCESS EVENT is executed), the associated event handler is called/performed and passed the defined arguments as parameters


You would usually define the event handlers somewhere in the initialization logic of your application
You insert the event triggers in strategic locations in your application logic


This simplifies how you handle critical logic in your app with software changes as well as software customization.


No need to do search and replaces of critical CALLs throughout your application when your rename and rework them, just change the assigned event handler in one place.


Also, it makes easier to customize certain aspects of your app. Imagine you have created a special invoice printing program for a few clients instead of the standard one.
In your app logic you just have a
PROCESS EVENT "PrintInvoice",invoice_num$
Wherever an invoice is supposed to be printed.


In your initialisation logic you'll have
ON PROCESS EVENT "PrintInvoice" CALL "invoice.pxp;print_std" for all clients
ON PROCESS EVENT "PrintInvoice" CALL "invoice.pxp;print_special" for a few clients
The program name could even be stored in some parameter file, or whatever solution you see fit


Hope that helps.
Stéphane Devouard
Portfolio | Work

Gilles

  • Silver Member
  • ***
  • Posts: 27
    • View Profile
Re: Event handling
« Reply #2 on: January 15, 2021, 10:40:56 AM »
Sure that helps
Thank you Stéphane