SPAWN

From Lianjapedia
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'. 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.

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)
    ? "Printing completed."
endif