diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 67e97fc3d1..cdf4b0c7d7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,12 @@ +19990613 23:00 CET Eddie Runia + * source/rtl/environ.c + __Run() added for Borland and DJGPP + + tests/working/dosshell.prg + Only for DOS, OS/2 & Windows + + tests/working/cmphello.prg + This file compiles hello. Also usuable for Linux / Unix, if the system() + command functions on their compilers :-) + 19990613 16:35 CET Eddie Runia * tests/working/strip.prg; tests/working/inherit.prg; tests/working/dynobj.prg diff --git a/harbour/source/rtl/environ.c b/harbour/source/rtl/environ.c index be7c80d157..8226b17e2a 100644 --- a/harbour/source/rtl/environ.c +++ b/harbour/source/rtl/environ.c @@ -11,6 +11,7 @@ #if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) #include + #include #endif #ifdef __WATCOMC__ @@ -28,11 +29,13 @@ #endif #endif +HARBOUR HB___RUN(void); HARBOUR HB_GETENV(void); HARBOUR HB_OS(void); HARBOUR HB_VERSION(void); static SYMBOL symbols[] = { +{ "__RUN" , FS_PUBLIC, HB___RUN , 0 }, { "GETENV" , FS_PUBLIC, HB_GETENV , 0 }, { "OS" , FS_PUBLIC, HB_OS , 0 }, { "VERSION", FS_PUBLIC, HB_VERSION, 0 } @@ -212,3 +215,41 @@ HARBOUR HB_GETENV(void) else _retc(""); } + +/* + * $FunctionName$ + * __RUN + * $Syntax$ + * __RUN( ) + * $Argument$ + * Command to execute + * $Description$ + * This command runs an external program. Please make sure that you have + * enough free memory to be able to run the external program. + * Do not use it to run Terminate and Stay Resident programs (in case of DOS) + * since it cause several problems + * $Examples$ + * __Run( "edit "+cMyTextFile ) // Runs an external editor + * __Run( "command" ) // Gives a DOS shell (DOS only) + * $Files$ + * source/rtl/environ.c + * Run an external program + * $See also$ + * ErrorLevel() ?? // TO DO : Is this correct ? + */ +HARBOUR HB___RUN( void ) +{ +#if defined(__TURBOC__) || defined(__BORLANDC__) || defined(__DJGPP__) + if( _pcount() == 1 ) /* Parameter passed */ + { + system( _parc( 1 ) ); + } + else + { + PHB_ITEM pError = _errNew(); + _errPutDescription( pError, "RUN: Incorrect number of arguments" ); + _errLaunch( pError ); + _errRelease( pError ); + } +#endif +} diff --git a/harbour/tests/working/cmphello.prg b/harbour/tests/working/cmphello.prg new file mode 100644 index 0000000000..5870b23735 --- /dev/null +++ b/harbour/tests/working/cmphello.prg @@ -0,0 +1,19 @@ +// +// Compile Hello +// +// This program compiles hello.prg +// +function Main() + + local cOs := Upper( OS() ) + + QOut( "About to compile Hello.prg" ) + QOut() + if at( "WINDOWS", cOs ) != 0 .or. at( "DOS", cOs ) != 0 .or. ; + at( "OS/2", cOs ) // OS/2, DOS, Windows version + __Run( "..\..\bin\harbour.exe hello.prg /gHRB" ) + else // Unix / Linux version + __Run( "../../bin/harbour.exe hello.prg /gHRB" ) + endif + QOut( "Finished compiling" ) +return nil diff --git a/harbour/tests/working/dosshell.prg b/harbour/tests/working/dosshell.prg new file mode 100644 index 0000000000..50f8d8fb8f --- /dev/null +++ b/harbour/tests/working/dosshell.prg @@ -0,0 +1,20 @@ +//NOTEST // It is very frustrating if this one is auto-tested +// +// DosShell +// +// This program shell to DOS +// +// Warning : DOS only +// +function Main() + + local cOs := Upper( OS() ) + + if at( "WINDOWS", cOs ) != 0 .or. at( "DOS", cOs ) != 0 + QOut( "About to shell to DOS.." ) + __Run( GetEnv("COMSPEC") ) + QOut( "Hey, I am back !" ) + else + QOut( "Sorry this program is for Windows and DOS only" ) + endif +return nil