SPAWN

From Recital Documentation Wiki
Jump to: navigation, search

Purpose

Execute an external program and optionally wait for its completion


Syntax

SPAWN | !! <os-command>


See Also

ACTIVEPID(), CANCELPID(), SPAWNPID()


Description

The SPAWN command is synonymous with the !! command. These commands provide the facility for executing external programs, in the 'background', from within the Recital/4GL. The SPAWN command differs from the RUN command in that the specified <os command> executes in parallel without waiting until command execution is complete. It is particularly useful for generating reports from shared tables. When running a command in the background, terminal output is disabled for the background command if it is running the Recital/4GL.

The SPAWNPID() function returns the identity of the spawned process. The ACTIVEPID(<pid>) function returns .T. if the specified process is still active and .F. otherwise. The CANCELPID(<pid>) function returns .T. if the specified process could be 'killed' and .F. otherwise. A spawned process will only remain active while the user remains logged in. All spawned processes will be terminated when the user logs out.


Example

spawn db printrep
pid = spawnpid()
on escape killed = cancelpid(pid)
if not activepid(pid)
    set message to "Printing completed."
endif


Products

Recital Server, Recital