waiting_20for_20an_20external_20program_20to_20terminate
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
waiting_20for_20an_20external_20program_20to_20terminate [2018/03/31 13:19] – external edit 127.0.0.1 | waiting_20for_20an_20external_20program_20to_20terminate [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====Waiting for an external program to terminate===== | =====Waiting for an external program to terminate===== | ||
- | //by Richard Russell, June 2006//\\ \\ The ***RUN** command (or, equivalently, | + | //by Richard Russell, June 2006//\\ \\ The ***RUN** command (or, equivalently, |
+ | |||
+ | <code bb4w> | ||
SYS " | SYS " | ||
- | Here **prog$** is the name of the application you want to run (e.g. "" | + | </ |
+ | |||
+ | Here **prog$** is the name of the application you want to run (e.g. "" | ||
+ | |||
+ | <code bb4w> | ||
SYS " | SYS " | ||
- | However the use of **ShellExecute** has one significant disadvantage compared to the use of ***RUN**: it does //not// wait until the external application has terminated. Control will be returned to your BASIC program immediately.\\ \\ To overcome this disadvantage you can use the procedure listed below. This behaves like **ShellExecute** except that it does not return until the external application has terminated:\\ | + | </ |
+ | |||
+ | However the use of **ShellExecute** has one significant disadvantage compared to the use of ***RUN**: it does //not// wait until the external application has terminated. Control will be returned to your BASIC program immediately.\\ \\ To overcome this disadvantage you can use the procedure listed below. This behaves like **ShellExecute** except that it does not return until the external application has terminated: | ||
+ | |||
+ | <code bb4w> | ||
DEF PROCexecuteandwait(prog$, | DEF PROCexecuteandwait(prog$, | ||
LOCAL sei{}, res% | LOCAL sei{}, res% | ||
Line 27: | Line 37: | ||
SYS " | SYS " | ||
ENDPROC | ENDPROC | ||
- | So, by analogy with the example above, you might call this procedure as follows:\\ | + | </ |
+ | |||
+ | So, by analogy with the example above, you might call this procedure as follows: | ||
+ | |||
+ | <code bb4w> | ||
PROCexecuteandwait(" | PROCexecuteandwait(" | ||
- | If you need to know the exit code (ERRORLEVEL) of the program then the above code can be converted to a function which returns this value:\\ | + | </ |
+ | |||
+ | If you need to know the exit code (ERRORLEVEL) of the program then the above code can be converted to a function which returns this value: | ||
+ | |||
+ | <code bb4w> | ||
DEF FNexecuteandwait(prog$, | DEF FNexecuteandwait(prog$, | ||
LOCAL sei{}, res% | LOCAL sei{}, res% | ||
Line 52: | Line 70: | ||
SYS " | SYS " | ||
= res% | = res% | ||
- | You might call it as follows:\\ | + | </ |
+ | |||
+ | You might call it as follows: | ||
+ | |||
+ | <code bb4w> | ||
exitcode% = FNexecuteandwait(" | exitcode% = FNexecuteandwait(" | ||
+ | </ |
waiting_20for_20an_20external_20program_20to_20terminate.1522502391.txt.gz · Last modified: 2024/01/05 00:16 (external edit)