PxPlus User Forum

Twitter Twitter Twitter

Author Topic: looking for a cancel request  (Read 619 times)

Thomas Bock

  • Diamond Member
  • *****
  • Posts: 127
    • View Profile
looking for a cancel request
« on: August 29, 2018, 08:29:07 AM »
During long processing we display a "Please wait ..." dialog with an optional cancel button. In many cases the working program logic resides much deeper in the call stack than the front end parts. So these programs have no clue of that button and therefore cannot look for a cancel request of the user.
Is there a way to manage a cancel request though (PxPlus V13 and V14)?

Allen Miglore

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
    • UnForm
Re: looking for a cancel request
« Reply #1 on: August 29, 2018, 08:57:49 AM »
You could set/monitor a global variable (%canceled=1) or gbl value (gbl("canceled",err=*next)="1").   Or if multiple processes, you could set/monitor a file or key in a file.

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3368
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: looking for a cancel request
« Reply #2 on: August 29, 2018, 09:23:01 AM »
If I understand your question the problem is that when running the application you want to receive some form of signal from the user to stop.   The challenge is doing this without having to "poll" the workstation looking for input.

One thing you could try would be to create a button whose CTL event is -1001 as this emulate a ESCAPE/BREAK being pressed.  You can thus simply create a small window in the center of the screen with this button then have a SETESC in your code trap the event to allow for an orderly exit.  If desired you could also include an animated GIF on the window to show progress to your user.

Personally though I would use the PxPlus progress bar utility and issue a call to it on a regular basis in your logic.  This provides not only a means to do an orderly shutdown but also a visual indication that work is being done.  There are two (2) options with PxPlus progress bars, one that allows you to display the percentage complete and one that just provides a ongoing progress display.  If you know how much of the work has been done I recommend the former option (the percentage complete bar).

BTW: It should be noted that the PxPlus progress bar has built-in logic to only update the screen every few seconds instead of every time it is called.  This helps overall performance which can be impacted by repeatedly screen updates.