spawn
Pass the specified command to the operating system.
spawn OSCommand
Example: spawn "rm -i *.p[0-9][0-9] "
Parameters
Parameter | Data Type | Description |
---|---|---|
OSCommand | String | Operating system command. The string can be up to 2047 bytes. |
Return Values
Value | Meaning |
---|---|
<0 |
An operating system error occurred. |
0
|
OSCommand was successfully spawned. $result is set to the value returned by OSCommand. |
Use
Allowed in all component types.
Description
The spawn statement clears the screen and passes the OSCommand to the operating system on which the application is running. In a client/server environment, this is the client machine.
You may need to use the refresh statement to repaint the Uniface screen following spawn.
The OSCommand is spawned as an
asynchronous process, making it appropriate for interactive applications. To run a synchronous OS
command and catch the result, implement an OS service and use activate to call
the COMMAND
operation on the service.
Windows
On Microsoft Windows platforms, you can spawn the command as a synchronous process by prefixing the command with a hash character (#). In the following example, the Uniface application is suspended until the program conv_val ends:
; start conv_val to convert file specified in vFile spawn "#conv_val.exe %%vFile.raw" ; load processed values into vValues fileload "%%$1.dat",vValues
Unix
Under Unix, a spawned process that detaches itself from the parent process can be used for interprocess communication.
You can spawn the command as a synchronous process using the standard command:
spawn OSCommand
You can also spawn the command as an asynchronous call by using the ampersand character (&) at the end of the command:
spawn OSCommand&
Interactively Removing Print Files
The following example uses the
spawn statement to interactively remove any print files (those ending in
.p00 through .p99). This example uses the Unix
rm
command, which should be in the user's path (Unix systems only).
trigger detail spawn "rm -i *.p[0-9][0-9] " askmess "Press space bar to return."," ",-1 refresh end