Porovnávané verzie
Kľúč
- Tento riadok sa pridal
- Riadok je odstránený.
- Formátovanie sa zmenilo.
RUN action
Function
The action runs a specified external program.
Declaration
Blok kódu | ||||
---|---|---|---|---|
| ||||
RUN "program name" [HIDE] SYNC/ASYNC [paramExpr_Str] [TIMEOUT timeOutExprStr_Int] |
or
Blok kódu | ||||
---|---|---|---|---|
| ||||
intIdent_Int := RUN "program name" [HIDE] SYNC [paramExpr_Str] [TIMEOUT timeOutExpr_Int] |
Blok kódu | ||||
---|---|---|---|---|
| ||||
RUNEX _toExec [HIDE] SYNC/ASYNC [paramExpr_Str] [TIMEOUT timeOutExprStr_Int] |
Blok kódu | ||||
---|---|---|---|---|
| ||||
intIdent_Int := RUNEX _toExec [HIDE] SYNC [paramExpr_Str] [TIMEOUT timeOutExpr_Int] |
Parameters
"program name" | in | Executable program name (optionally in quotation marks). |
intIdent_Int | out | Identifier - program return code. |
HIDE | in | Optional parameter - hide the window of the program you want to run. |
SYNC | in | Synchronous program run (waiting for termination). |
ASYNC | in | Asynchronous program run. |
paramExpr_Str | in | Expression of String type, the result value of which will create parameters of the running program. |
TIMEOUT timeoutExpr_Int | in | Expression of the Int type -the maximum program running time [s]. |
_toExec | in | Identifier of the text type. |
Description
The RUN action will run the program determined by text string "program name". RUNEX action will run the program determined by value of identifier of text type _toExec.
In the first type of the declaration, it is able to specify whether the program will be run synchronously (SYNC), or asynchronously (ASYNC). The second type is always asynchronous. After the program termination, its return code is assigned to the identifier of the Int type.
If the maximal program running time is limited by the keyword TIMEOUT and the program is not to be terminated in this time limit, the program is to be terminated and the program and the return value (for the first type) gets the value _ERR_TIME_OUT.
In some cases, the parameter program name must be created on the basis of text operations. It is recommended to use RUNEX action to run program determined by value of text identifier _toExec.
The same result is reached by RUN action but the program name must be an empty text string and whole command is to be declared as parameter using the expression paramExpr_Str (see the example below).
For Linux/Raspberry PI it is necessary to enter separate "program name" and parameters, e.g.
RUN "/usr/bin/ncftpget" SYNC _paramStr
If the "program name" is empty or contains parameters, the program will not start.
If RUN action is used with the return code and starting the program failed, return code (intIdent_Int) will have an invalid value.
Note:
For OpenVMS only asynchronous - without parameters.
Example
The following example copies the file d:\d2000.v70\prefix\sqlback\syscfg.db into the directory c:\archive using standard facilities of the operating system (shell will run the command copy).
Blok kódu | ||||
---|---|---|---|---|
| ||||
; Copying the file ; Source file TEXT _copySrc = "d:\d2000.v70\prefix\sqlback\syscfg.db" ; Target directory TEXT _copyDst = " c:\archive" ; Parameters for the command copy TEXT _switch = "/Y " ; Return code INT _ret _ret := RUN "cmd /C copy " SYNC _switch + _copySrc + _copyDst ; or whole command declared as expression ; _ret := RUN "" SYNC "cmd /C copy + _switch + _copySrc + _copyDst IF _ret # _ERR_NO_ERROR THEN ; error ENDIF END |