Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Hull and Outfitting

Progress and Interrupt Methods

  • Last UpdatedFeb 08, 2023
  • 2 minute read

Form and Gadget callbacks may take a long time to execute, so it is often desirable to use the Progress Indicator field on the Main Window's status bar (along the bottom) to indicate continuing progress to the user. Additionally for some callback operations it may be possible and desirable to allow the user to interrupt the operation and choose to cancel it. The FMSYS methods Progress, setProgress, Interrupt and setInterrupt allow this to be achieved.

Your callback which provides the desired operation, must be cyclical so that there is some repeated access point where you can report progress (approximately as a percentage of the total task), and check to see if the user has clicked a stop button which you have provided on some displayed form.

In your callback function you must first notify the system of the identification of the stop button using the FMSYS method SetInterrupt:

!!FMSYS.setInterrupt(!!fmstop.stopButton )

Then at an appropriate point in the callback, check to see if the stop button has been pressed using the FMSYS Interrupt method, and exit with a message if it has:

-- initialize progress bar

!!FMSYS.setProgress(0)

do !next from 1 to 50

 ...

 !!RoutePipe( !next, . . . ) $*Route next pipe

 ...

-- Update the progress bar - first update the percentage

completion

!percent = ...

!!FMSYS.setProgress( !percent )

 -- Check if user pressed interrupt button

 if ( !!FMSYS.Interruppt() ) then

 return error 1 'Processing aborted'

  endif

enddo

Following is the PML code for a simple interrupt form !!fmstop.pmlfrm:

$* F&M test harness: Stop form for interrupt management

setup form !!fmstop dialog NoAlign

title 'STOP (!!fmstop)'

path down

para .stopText text |Press to quit task| width 20

button .stopButton |Quit| width 25 height 2

exit

define method .fmstop()

--Constructor

-- define callbacks

!this.firstShownCall = |!this.stopButton.background =

 'red'|

endmethod

TitleResults for “How to create a CRG?”Also Available in