RUN command

2,102 views
Skip to first unread message

Adrian Semcheff

unread,
Nov 20, 2012, 9:38:21 AM11/20/12
to harbour-users
Hi!

I'm working with
 
Harbour 3.0 console mode

The problem is with the RUN command.
 
For some things going well, but if for example I do the following:
 
RUN DEL LIST*.TXT
RUN COPY pepe.dbf \
etc.
 
Ignore the commands (in clipper 5.3 work fine)


 
Now if I do:
 
RUN notepad.exe pepe.prg
 
It works well.
 
Thanks, Adrian.

SD

unread,
Nov 20, 2012, 10:23:17 AM11/20/12
to harbou...@googlegroups.com
On Tuesday, November 20, 2012 8:08:22 PM UTC+5:30, Adrian Semcheff wrote:
The problem is with the RUN command.


Dear Adrian:

Try by using HB_RUN

cFilename:="Report.txt"
hb_run(cFilename) 

The added advantage here is that we do not need to call the notepad.exe application here, the OS (windows) will use the default application assigned for this kind of file .

This has worked for me to open excel files (yes am also using Harbour 3.0) ....

HTH...

Regards,
Swapan

"José M. C. Quintas"

unread,
Nov 20, 2012, 11:00:43 AM11/20/12
to harbou...@googlegroups.com
In Harbour 3.0 *** and Clipper:

RUN ("del List*.txt")
RUN ("COPY pepe.dbf \")

*** Don't works in Harbour 3.2

Jos� M. C. Quintas
> Thanks, Adrian. --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users

vszakats

unread,
Nov 20, 2012, 11:09:58 AM11/20/12
to harbou...@googlegroups.com
I just answered to this last week, to you Jose.
You even publicized the answer on another forumÉ
but left it without any reaction here, and now you 
have seem to have forgotten it.

Anyways, same answer applies here.

-- Viktor


On Tuesday, November 20, 2012 5:00:44 PM UTC+1, José M. C. Quintas wrote:
In Harbour 3.0 *** and Clipper:

RUN ("del List*.txt")
RUN ("COPY pepe.dbf \")

*** Don't works in Harbour 3.2

Jos� M. C. Quintas

"José M. C. Quintas"

unread,
Nov 20, 2012, 11:55:43 AM11/20/12
to harbou...@googlegroups.com
In this post I answer the user question.
And alerts user for difference in Harbour 3.2.


After that post in pctoledo forum, when compiling new CVS sources, don't works again.
May be I use changed sources when make the first test, and CVS don't update changed sources.
Since that, I use run.c from Harbour 3.0.
Need make more tests before post anything about it (tests without mix code).

José M. C. Quintas

vszakats

unread,
Nov 20, 2012, 12:06:49 PM11/20/12
to harbou...@googlegroups.com

On Tuesday, November 20, 2012 5:55:45 PM UTC+1, José M. C. Quintas wrote:
In this post I answer the user question.
And alerts user for difference in Harbour 3.2.


After that post in pctoledo forum, when compiling new CVS sources, don't works again.
May be I use changed sources when make the first test, and CVS don't update changed sources.
Since that, I use run.c from Harbour 3.0.
Need make more tests before post anything about it (tests without mix code).

I don't know what "don't works" means after you confirmed 
that it works.

Regardless, what I suggested DOES work in 3.2 SVN (we don't 
use CVS since 2007):

   RUN ( GetEnv( "COMSPEC" ) + " /c " + "dir *.*" )

hb_run() works exactly the same way as RUN.

Most probably also in pre 3.2 versions, but I don't 
have them at hand ATM.

-- Viktor

Adrian Semcheff

unread,
Nov 20, 2012, 2:05:32 PM11/20/12
to harbou...@googlegroups.com
YES!!!

Works!!!

With  RUN ( GetEnv( "COMSPEC" ) + " /c " + "dir *.*" )

Solve de problem.

Thank's

Adrian..

2012/11/20 vszakats <har...@syenar.net>

"José M. C. Quintas"

unread,
Nov 20, 2012, 2:55:38 PM11/20/12
to harbou...@googlegroups.com
Finally.

RUN ("temp\filename.bat")

Works ok in Harbour 3.0, in any GT.
In Harbour 3.2 only on console application.
I use gtwvt in application, but was making tests without it.

About SVN:
I was thinking that CVS and SVN was the same thing.
I use this:
svn export https://harbour-project.svn.sourceforge.net/svnroot/harbour-project/trunk/harbour        d:\cvsfiles\harbour32

José M. C. Quintas

"José M. C. Quintas"

unread,
Nov 20, 2012, 3:03:33 PM11/20/12
to harbou...@googlegroups.com
Same thing with:

RUN (GetEnv("COMPSPEC") + " / c " + cCmd)

On Harbour 3.2 depends GT.

José M. C. Quintas

vszakats

unread,
Nov 20, 2012, 3:28:52 PM11/20/12
to harbou...@googlegroups.com


On Tuesday, November 20, 2012 8:55:42 PM UTC+1, José M. C. Quintas wrote:
Finally.

? It's the same I wrote to you and what you reposted.
 
RUN ("temp\filename.bat")

Works ok in Harbour 3.0, in any GT.
In Harbour 3.2 only on console application.
I use gtwvt in application, but was making tests without it.

If "don't work" means that you don't see the output 
(but you still didn't define it, so I have to resort to guessing), 
in GTWVT it wouldn't work either way, because Windows 
OS's command shell doesn't know how to echo output onto 
Harbour's proprietary GUI window that GTWVT uses.
If you need such feature, use GTWIN. Or catch the 
output using hb_processRun() and display it manually 
on GTWVT screen.

As a general suggestion it's best to avoid making 
external calls for several good reasons. It was usually 
bad hack in Clipper (or even dBase) done out of necessity.
Harbour has much superior, modern and portable ways
to solve these in many cases.

F.e. the thread starter two lines can be converted to 
this native Harbour code:
---
   #include "directry.ch"
   AEval( Directory( "*.txt" ), {| file | FErase( file[ F_NAME ] ) } )
   hb_FCopy( "pepe.dbf", hb_ps() )
---

These offer much more error conrol, they are fully 
portable and run much more efficiently and in all 
situations.

About SVN:
I was thinking that CVS and SVN was the same thing.
I use this:
svn export https://harbour-project.svn.sourceforge.net/svnroot/harbour-project/trunk/harbour        d:\cvsfiles\harbour32

Both are VCS systems, but they are different software:

CVS is outdated solution for the VCS problem, and 
SVN starts to become one as well. For modern stuff, see:

-- Viktor

"José M. C. Quintas"

unread,
Nov 20, 2012, 6:02:58 PM11/20/12
to harbou...@googlegroups.com
Don't works means that an window is open, I can't see what happen because occurs in less than one second, can't pause, seems an empty window.
If BAT have "pause", pause don't occurs.

There are clients using windows 98, xp, vista, windows 7, with or without server.
I don't need an better solution, only an compatible solution that works.
run.c solves for me.

To open html, xls, pdf, and another file types, I use ShellExecute() API.
If Harbour have RUN and HB_RUN, then I think that RUN can continue Clipper compatible.

Change is generating too may questions, and will generate much more when released as oficial.

From same forum, see some suggested solutions:
http://www.pctoledo.com.br/forum/viewtopic.php?f=4&t=13108&p=75533&hilit=run#p75533

José M. C. Quintas

vszakats

unread,
Nov 20, 2012, 6:37:43 PM11/20/12
to harbou...@googlegroups.com
On Wednesday, November 21, 2012 12:02:59 AM UTC+1, José M. C. Quintas wrote:
Don't works means that an window is open, I can't see what happen because occurs in less than one second, can't pause, seems an empty window.
If BAT have "pause", pause don't occurs.

There are clients using windows 98, xp, vista, windows 7, with or without server.
I don't need an better solution, only an compatible solution that works.
run.c solves for me.

Someone who prefers clean, platform independent code, 
- without dependence on MS-DOS batch files and 
MS-DOS command interpreter - might find it useful 
though.
 
To open html, xls, pdf, and another file types, I use ShellExecute() API.

Harbour features WAPI_SHELLEXECUTE() for this, yet 
in most forums people tackle custom C code to reinvent it 
less cleanly.
 
If Harbour have RUN and HB_RUN, then I think that RUN can continue Clipper compatible.

This is largely a platform compatibility issue, not a 
Clipper one. "RUN" needs to work on all platforms 
and now they work similarly on all platforms, uniformly 
using Harbour's low-level Process API, behaving 
the same way on all platforms and supporting the same 
Harbour level features on all platforms, including 
codepage translation.

Change is generating too may questions, and will generate much more when released as oficial.

Yes, you yourself repeated it three or four times. 

Also remember you're using unstable development 
version of Harbour (3.2.0dev), so it may even change 
before the final release (although I don't have such 
plans ATM). If you have a suggestion how to solve 
the codepage problem and compatibility problems 
with other platforms, please make it on the devel list.

As for solutions:

RUNSHELL() is the function to call the shell as 
I told you a while ago (without any reaction of 
course), it's available in hbxpp.hbc. There is also 
WAPI_SHELLEXECUTE() to launch documents.
There is also WIN_RUNDETACHED(), both in 
hbwin.hbc, and there is portable HB_PROCESSRUN() 
in core, if you need to call external process in 
well controlled way. There is also HB_PROCESS*() 
API for even more control. And of course you may 
use HB_RUN()/RUN/!/__RUN() with the command 
shell.

These have been repeated many times in Harbour 
forums in last years.

-- Viktor

"José M. C. Quintas"

unread,
Nov 20, 2012, 9:02:43 PM11/20/12
to harbou...@googlegroups.com
Seems to be anything about relative path.
In VB, when application is loaded from BAT, VB assumes DOS PATH to run external EXEs.
What is default PATH to RUN in Harbour 3.2 GUI when loading from BAT file?

José M. C. Quintas

vszakats

unread,
Nov 20, 2012, 9:15:42 PM11/20/12
to harbou...@googlegroups.com
On Wednesday, November 21, 2012 3:02:46 AM UTC+1, José M. C. Quintas wrote:
Seems to be anything about relative path.
In VB, when application is loaded from BAT, VB assumes DOS PATH to run external EXEs.
What is default PATH to RUN in Harbour 3.2 GUI when loading from BAT file?

Environment is not altered by Harbour in any runner 
functions, so it's whatever inherited from your application 
process.

You can reveal the actual value on your system using 
ECHO command in your batch file.

-- Viktor

"José M. C. Quintas"

unread,
Nov 20, 2012, 11:00:45 PM11/20/12
to harbou...@googlegroups.com
I lost all my day making tests with RUN.
Until now, RUN don't makes what I want.
Will continue using run.c from Harbour 3.0.

Try solve using absolute path, but HB_Argv(0) is not the same as Harbour 3.0.
I post this in harbour-devel.

José M. C. Quintas

Swaroop Joshi

unread,
Dec 12, 2017, 1:45:02 PM12/12/17
to Harbour Users

Hi,

    I am also facing some problem in Run command

   RUN CD\FA\CLIENT

   does not change the Directory and afterwards i have written
   
   ? CURDIR()

   Displays the same Directory from where the program runs 

   D:\FA\PRG

   Please Help 



    
 
Message has been deleted

oleksa

unread,
Dec 12, 2017, 1:57:32 PM12/12/17
to harbou...@googlegroups.com
Hi!

Try next func DirChange( <cDirectory> ) --> nError

Regards,
Alexey Myronenko

12 грудня 2017, 20:46:56, від "Swaroop Joshi" <swaroop...@gmail.com>:
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Swaroop Joshi

unread,
Dec 12, 2017, 2:22:53 PM12/12/17
to Harbour Users

DirChange("CD\FA\CLIENT")

does not change the Current Directory

? DirChange("CD\FA\CLIENT") 

Gives Value = 3


Swaroop Joshi

unread,
Dec 12, 2017, 2:30:10 PM12/12/17
to Harbour Users
Thanks Very much for your valuable reply,

I Got it, Actually i changed to 

DirChange("\FA\CLIENT")

and its working fine, 

oleksa

unread,
Dec 12, 2017, 2:30:46 PM12/12/17
to harbou...@googlegroups.com
In your case "CD" is a command or this is folder?

Look a doc for DirChange at https://github.com/harbour/core/blob/master/doc/en/dirdrive.txt

Regards,
Alexey Myronenko

12 грудня 2017, 21:22:56, від "Swaroop Joshi" <swaroop...@gmail.com>:

Swaroop Joshi

unread,
Dec 12, 2017, 2:40:34 PM12/12/17
to Harbour Users
Yes "CD" that was my mistake, I got it later

Thanks
Reply all
Reply to author
Forward
0 new messages