Application Developer Guide > Interapplication Communication for Windows > Noninteractive Applications
  

Noninteractive Applications
If you are writing a noninteractive application—one for which no input is required at the PV-WAVE prompt—then you may need to build some handling into your code for any nonblocking PV-WAVE widgets. You may also need to make special arrangements for graphic-window resizing.
Using Nonblocking PV‑WAVE Widgets
When PV-WAVE's input is not coming from an interactive terminal, then the nonblocking Widget event loop (WwLoop,/NoBlock, for example) may not behave as expected. This event loop is normally serviced as PV-WAVE “watches” the keyboard. Thus, when you do not have an interactive terminal, the event loop is not serviced.
Some examples of noninteractive applications include:
*Running commands from within a PV-WAVE procedure or batch file using @ or .RUN)
*Sending commands to PV-WAVE via a pipe using wavecmd()
*Running PV-WAVE in batch mode or redirecting standard input
*Using cwavec() or cwavefor() (see the Note, below)
In these situations, it becomes the programmer’s responsibility to service the event loop. If you are running commands in a procedure file, then this can be as simple as exiting back to the command prompt.
If you are running PV-WAVE as a background process, however, or in some mode where you need a nonblocking event loop but do not have an interactive terminal, then you will need call WtProcessEvent periodically to service the event loop. To process all pending events, you call this function using the /Drain keyword .
Example
Say you have the following in a procedure file:
NAVIGATOR  
; A non-blocking Widget application 
WHILE ( WtProcessEvent(/Drain) NE 1 ) DO BEGIN $
PRINT, 'Still alive' & $
WAIT, 0.1
PRINT, 'Exiting'
EXIT
When you execute this procedure at the PV-WAVE prompt, the WHILE loop causes WtProcessEvent to be called until the widget application is exited. Of course, in a real case, you would do some other processing rather than just PRINT and WAIT, but the point is that you need to call WtProcessEvent periodically and check its return status (so you know when the Widget application is finished).
 
note
When you use cwavec() and cwavefor(), the normal behavior for WwLoop,
/NoBlock
is to ignore the keyword and actually block. So if you call cwavec() to execute a nonblocking Widget, PV-WAVE will service its own event loop until the Widget exits. If you wish to have the event loop nonblocking, then you must call WtProcessEvent periodically to process the events and use WwLoop, NoBlock=2 to force the nonblocking behavior.
Window Resizing
PV-WAVE will not automatically recognize resizing of graphic windows when it is not being run interactively (for example, using wavecmd() or cwavec()). To notify PV-WAVE of window resizing use:
WSET, winid
This command has the effect of updating the !D system variable. See WSET for more information.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.