-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_run.prg
66 lines (41 loc) · 1.32 KB
/
test_run.prg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma BEGINDUMP
#include "hbapi.h"
#include "hbapierr.h"
#include "hbapigt.h"
#include "hbapiitm.h"
#include "hbapifs.h"
/* TOFIX: The screen buffer handling is not right for all platforms (Windows)
The output of the launched (MS-DOS?) app is not visible. */
HB_FUNC( __RUN_SYSTEM )
{
const char * pszCommand = hb_parc( 1 );
int iResult;
if( pszCommand && hb_gtSuspend() == HB_SUCCESS )
{
char * pszFree = NULL;
iResult = system( hb_osEncodeCP( pszCommand, &pszFree, NULL ) );
hb_retni(iResult);
if( pszFree )
hb_xfree( pszFree );
if( hb_gtResume() != HB_SUCCESS )
{
/* an error should be generated here !! Something like */
/* hb_errRT_BASE_Ext1( EG_GTRESUME, 6002, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT ); */
}
}
}
#pragma ENDDUMP
_cmd := "c:\windows\system32\notepad.exe"
_cmd := "start f18_editor.cmd c:\Documents and Settings\hbakir\.f18\bringout_2012\outf.txt"
_cmd := "copy test_run.xprg test_copy.txt"
_cmd := 'echo f18_test2 > "%HOME%\test copy.txt"'
? "run"
_stderr := ""
_stdout := ""
//_ret := hb_processrun(_cmd, @_stderr, @_stdout)
//_ret := (_cmd, NIL, NIL, NIL)
_ret := __run_system(_cmd)
? "stderr", _stderr
? "stdout", _stdout
? _ret
inkey(0)