ShellExecute()

2,514 views
Skip to first unread message

CCH

unread,
Feb 25, 2011, 9:51:03 PM2/25/11
to Harbour Users
Hi

I used to use 16bits FiveWin's WINEXEC() and in moving to 32 bits, I
found that ShellExecute() may be an equivalent function.

From http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx

HINSTANCE ShellExecute(
__in_opt HWND hwnd,
__in_opt LPCTSTR lpOperation,
__in LPCTSTR lpFile,
__in_opt LPCTSTR lpParameters,
__in_opt LPCTSTR lpDirectory,
__in INT nShowCmd
);

Does anyone know the actual syntax of ShellExecute() as supported by
Harbour/xHarbour ?

TIA

CCH
http://cch4clipper.blogspot.com

Maurizio la Cecilia

unread,
Feb 26, 2011, 5:20:13 AM2/26/11
to harbou...@googlegroups.com
Hi, see in contrib/hbwin/wapi_shellapi.c

HB_FUNC( WAPI_SHELLEXECUTE )
{
#if defined( HB_OS_WIN_CE )
   hb_retni( -1 );
#else
   void * hOperation;
   void * hFile;
   void * hParameters;
   void * hDirectory;

   hb_retnint( ( HB_PTRDIFF ) ShellExecute( ( HWND ) hb_parptr( 1 ),
                                            HB_PARSTR( 2, &hOperation, NULL ), /* edit, explore, open, print, play?, properties? */
                                            HB_PARSTRDEF( 3, &hFile, NULL ),
                                            HB_PARSTR( 4, &hParameters, NULL ),
                                            HB_PARSTR( 5, &hDirectory, NULL ),
                                            hb_parnidef( 6, SW_SHOWNORMAL ) /* nShowCmd */ ) );

   hb_strfree( hOperation  );
   hb_strfree( hFile       );
   hb_strfree( hParameters );
   hb_strfree( hDirectory  );
#endif
}

You'll need ti link hbwin, of course.
Best regards.
Maurizio

mastercom63

unread,
Feb 26, 2011, 8:59:13 AM2/26/11
to harbou...@googlegroups.com
#include <windows.h>
#include <shellapi.h>
#include "hbapi.h"
#include "hbapiitm.h"

// SHELLEXECUTE
// ============
// FIRST PARAMETER
// "edit"    Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
// "explore"    Explores a folder specified by lpFile.
// "find"    Initiates a search beginning in the directory specified by lpDirectory.
// "open"    Opens the item specified by the lpFile parameter. The item can be a file or folder.
// "print"    Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
//
// SECOND PARAMETER:
// file or folder name
//
HB_FUNC( SHELLEXECUTE )
{
    hb_retni( (int) ShellExecute(0,(LPCTSTR)hb_parc(1)(LPCTSTR)hb_parc(2),NULL,NULL,SW_SHOWNORMAL) );
}


hope it helps
Enrico

2011/2/26 CCH <chongh...@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

CCH

unread,
Feb 27, 2011, 8:10:42 AM2/27/11
to Harbour Users
Hi

TQVM for your feedback.
What worked nicely was something similar to :=

SHELLEXECUTE( 0, 0, "notepad.exe", "filename.txt", 0, 1 )

Cheers

CCH
http://cch4clipper.blogspot.com


On Feb 26, 9:59 pm, mastercom63 <masterco...@gmail.com> wrote:
> *#include <windows.h>
> #include <shellapi.h>
> #include "hbapi.h"
> #include "hbapiitm.h"
>
> // SHELLEXECUTE
> // ============
> // FIRST PARAMETER
> // "edit"    Launches an editor and opens the document for editing. If
> lpFile is not a document file, the function will fail.
> // "explore"    Explores a folder specified by lpFile.
> // "find"    Initiates a search beginning in the directory specified by
> lpDirectory.
> // "open"    Opens the item specified by the lpFile parameter. The item can
> be a file or folder.
> // "print"    Prints the file specified by lpFile. If lpFile is not a
> document file, the function fails.
> //
> // SECOND PARAMETER:
> // file or folder name
> //
> HB_FUNC( SHELLEXECUTE )
> {
>     hb_retni( (int)
> ShellExecute(0,(LPCTSTR)hb_parc(1)(LPCTSTR)hb_parc(2),NULL,NULL,SW_SHOWNORMAL)
> );
>
> }
>
> *hope it helps
> Enrico
>
> 2011/2/26 CCH <chonghwa.c...@gmail.com>

mastercom63

unread,
Feb 27, 2011, 8:23:32 AM2/27/11
to harbou...@googlegroups.com
yw!!
well ShellExecute windows function runs automatically a program for registered extensions, so you don't need to specify the executable name, but only the function you need ("open","edit" etc etc) on your file.
windows will use the program associated with the file extension to perform the operation (for "open" a txt file, windows would run notepad.exe).
if you do need to run a particular program, then you could use __run() function from within harbour, for example __run("c:\windows\system32\notepad.exe filename.txt")

cheers
Enrico


2011/2/27 CCH <chongh...@gmail.com>

Chee Chong Hwa

unread,
Feb 27, 2011, 8:46:52 AM2/27/11
to harbou...@googlegroups.com
Hi Enrico

Viktor mentioned hbrun(), how does this work ?

Chee Chong Hwa

unread,
Feb 27, 2011, 8:51:34 AM2/27/11
to harbou...@googlegroups.com
Hi Enrico


>do need to run a particular program, then you could use __run() function from within harbour, for example
> __run("c:\windows\system32\notepad.exe filename.txt")

Just did that and got this linker error msg

Error: Unresolved external '_HB_FUN__RUN' referenced from C:\MINIGUI\PROJECTS\PM
S4W7\.HBMK\WIN\BCC\PMS4WIN.OBJ
hbmk2: Error: Running linker. 2
ilink32.exe @C:\Users\CCH\AppData\Local\Temp\6uudrq.lnk

My function call was  _RUN("DPMSDNC.EXE")

Am I missing something ?

Maurizio la Cecilia

unread,
Feb 27, 2011, 10:00:55 AM2/27/11
to harbou...@googlegroups.com
Hi,
you missed an underscore.
The function is __run().
You can also issue a simple RUN command. The preprocessor will translate for you.
Best regards.
Maurizio

Viktor Szakáts

unread,
Feb 27, 2011, 11:45:28 AM2/27/11
to Harbour Users
Works the same as __RUN(), but it's a proper Harbour function,
not a compatibility/internal one:
HB_RUN( <cCommand> ) -> <nErrorLevel>

[ You can find this information in ChangeLog. ]

Viktor

On Feb 27, 2:46 pm, Chee Chong Hwa <chonghwa.c...@gmail.com> wrote:
> Hi Enrico
>
> Viktor mentioned hbrun(), how does this work ?
>
>
>
> On Sun, Feb 27, 2011 at 9:23 PM, mastercom63 <masterco...@gmail.com> wrote:
> > *yw!!
> > well ShellExecute windows function runs automatically a program for
> > registered extensions, so you don't need to specify the executable name, but
> > only the function you need ("open","edit" etc etc) on your file.
> > windows will use the program associated with the file extension to perform
> > the operation (for "open" a txt file, windows would run notepad.exe).
> > if you do need to run a particular program, then you could use __run()
> > function from within harbour, for example
> > __run("c:\windows\system32\notepad.exe filename.txt")
>
> > cheers
> > Enrico
>
> > *
> > 2011/2/27 CCH <chonghwa.c...@gmail.com>

Chee Chong Hwa

unread,
Feb 27, 2011, 8:04:19 PM2/27/11
to harbou...@googlegroups.com
Hi Viktor

Tx for the clarification.

hb_run("dpmsdnc.exe") works but as Console window... not what I wanted :-(
SHELLEXECUTE( 0, 0, "DPMSDNC.EXE") also works but using Windows:-)

Chee Chong Hwa

unread,
Feb 27, 2011, 8:06:30 PM2/27/11
to harbou...@googlegroups.com
Hi Enrico

I just checked and was using the underscore
 _RUN("DPMSDNC.EXE") 

BTW, HB_RUN"DPMSDNC.EXE") works/

mastercom63

unread,
Feb 28, 2011, 1:06:24 AM2/28/11
to harbou...@googlegroups.com

well i did use __run() (two underscores) but hb_run() is better because its a proper harbour function as Viktor said (thanks!).
i did not know hb_run() harbour function before, now i'm changing my sources in that way.

cheers
Enrico
 


2011/2/28 Chee Chong Hwa <chongh...@gmail.com>

Chee Chong Hwa

unread,
Feb 28, 2011, 5:19:22 AM2/28/11
to harbou...@googlegroups.com
Hi Viktor

What are the possible <nErrorLevel> values and their meaning  for

  HB_RUN( <cCommand> ) -> <nErrorLevel>

I have searched throughthe latest change log but cannot find any further information.

Cheers

On Mon, Feb 28, 2011 at 12:45 AM, Viktor Szakáts <harbo...@syenar.hu> wrote:

Viktor Szakáts

unread,
Feb 28, 2011, 6:50:40 AM2/28/11
to Harbour Users
Hi Chong Hwa,

On Feb 28, 11:19 am, Chee Chong Hwa <chonghwa.c...@gmail.com> wrote:
> What are the possible <nErrorLevel> values and their meaning  for
>   HB_RUN( <cCommand> ) -> <nErrorLevel>
>
> I have searched throughthe latest change log but cannot find any further
> information.

<nErrorLevel> is whatever numeric value returned by the process you
called.

Usually zero means OK, but the meaning of values is defined by the
called app.

Viktor

Bopdji Shah

unread,
Feb 28, 2011, 9:22:29 AM2/28/11
to harbou...@googlegroups.com
I am amused and concerned about this discussion.  In clipper, I used the Run command casually.  Even the good old "DBXL" a dBase III clone has this command, and we, the oldies, used it just as casually as USE and APPEND FROM commands.  (I can still use the Y2K modified DBXL under Windows XP command mode with excellent and immediate results)
Now we have a Windows compatible Clipper called Harbour and xHarbour, and we have a long discussion about using this well established function in dBase. Aren't we missing the Prime Directive  of creating Harbour in the first place?  Let me reannounce the Prime Directive as I see it.
"An xbase compatible application will use all the functionality of the older xbase applications and will do so in Windows, Linux and perhaps on MacOs, such that all the enhancements in the newer Operating Systems  shall be available to the new xbase compatible application, preferably using the syntax and the type of syntax we all are used in the older xbase applications."
In their enthusiasm to go for Object oriented programming and more and more additional features, a complex mostly unusable syntax has been created which will only hurt the project.



--

Viktor Szakáts

unread,
Feb 28, 2011, 10:48:43 AM2/28/11
to Harbour Users
Hi Bopdji

On Feb 28, 3:22 pm, Bopdji Shah <bop...@gmail.com> wrote:
> I am amused and concerned about this discussion.  In clipper, I used the Run
> command casually.  Even the good old "DBXL" a dBase III clone has this
> command, and we, the oldies, used it just as casually as USE and APPEND FROM
> commands.  (I can still use the Y2K modified DBXL under Windows XP command
> mode with *excellent and immediate* results)
> Now we have a Windows compatible Clipper called Harbour and xHarbour, and we
> have a long discussion about using this well established function in dBase.
> Aren't we missing the Prime Directive  of creating Harbour in the first
> place?  Let me reannounce the Prime Directive as I see it.

I'd be interested how would you get the errorlevel of the called
process in Clipper/dBase, using RUN command? (or __RUN()
function for that matter)

> *"An xbase compatible application will use all the functionality of the
> older xbase applications and will do so in Windows, Linux and perhaps on
> MacOs, such that all the enhancements in the newer Operating Systems  shall
> be available to the new xbase compatible application, preferably using the
> syntax and the type of syntax we all are used in the older xbase
> applications."*

Our goal is to be multiplatform (without words like "perhaps"
when it comes to tier one OSes, like Mac OS X), and to continue
where Clipper 5.x left it (while keeping full compatibility).

Command versions (if that's what you mean by "older xbase syntax")
if new functionality can be added by anyone interested, as simple 3rd
party header file. In last 12 years, nobody felt it interesting
enough
to actually do it, but I hope someone will, so you and other
interested
users can benefit.

Please also note that it was never our goal to be dBaseIII+
compatible. (only to the extend Clipper is compatible with it).

> In their enthusiasm to go for Object oriented programming and more and more
> additional features, a complex mostly unusable syntax has been created which
> will only hurt the project.

It's funny you mention OOP programming, because it hasn't even
been touched in this thread. But it's also a feature, just like
HB_RUN()
which you may just simply not use, if you don't like it, in this case
your app won't be affected by these new features at all.

Viktor

Qatan

unread,
Feb 28, 2011, 10:59:57 AM2/28/11
to harbou...@googlegroups.com
Hello Bopdji,
 
    I don't think that's the case here...
    I like the extended features and I belive those extra features can make Harbour alive today because now you can do other things you couldn't do with Clipper and for sure not with DBase but that´s my personal opinion, of course. - I respect your opinion -
    Those features will not affect your program if you don't use them. If you just want to use a simple RUN command, it will work as expected (like in Clipper) and that´s nice.
    I dont´t think it will hurt the project at all.
    My 2 cents...
    Regards,
 
Qatan

Bopdji Shah

unread,
Feb 28, 2011, 6:23:03 PM2/28/11
to harbou...@googlegroups.com
Victor:
Once upon a time, not so long ago, (about 1997-2006)   I used the databases available from Cia Factbook
https://www.cia.gov/library/publications/the-world-factbook/ to create, using clipper, my own databases with my own additions and after creating the databases, I used the same Clipper to make my own .shtml files resulting in a 3500 pages website.
Apart from manually downloading the flat database from CIA web site, I used clipper, to sift through the data using a combination of .txt and .dbf files and arriving finally at my .shtml files.  The programming changes for the new year "recompilation took three to four days (part time only) and the actual run of generating the SHTM took about 15-20 minutes on WIN95/98.
CIA site has changed considerably and now it mostly query language. At time the files were created as .txt and then renamed using DOS Rename command, etc, with RUN of dBase/Clipper.
Here is apart of one module.  You can see that to get round the "errorlevel" I used If file() syntax. 

proc split
para coun
PRIVATE aFiles := { "maps","head","intr","geog","
envi","peop","heal","govr","poli","dipl","econ","comm","tran","mili","issu" }

set talk off

set safety off

crlf=chr(13)+chr(10)
dirs="cia"+"\" // the original download directory
**coun="ch"  // this refers to country name as given by CIA (not TLD name)
run md &coun  // make a directory with that name
dirr=coun+"\"
flhtml=dirs+coun+".htm"  // the original .html file as downloaded
flmain=dirr+"main.dbf" // create main temporarily for convert file to database
cname=""  // variable for country name when found in text
tld="  "
intro="yes"   // variable to see if there is an introduction section

select 1
**use txt.mod
run copy txt.mod &flmain //plain one 250 character field in file
use &flmain
append from &flhtml sdf //HTML file converted to main database
go top
ct=1
maxct=len(aFiles)  // number of section to be created
do while ct<(maxct+1)
  newname=aFiles[ct]  // get the section name
  if newname="intr" .and. intro="no" // if no intro section, skip it
    ct=ct+1
    newname=aFiles[ct]
  endif
  ** newname will have something like "geog" or "econ"
  do onesect with newname  // do one section
  ct=ct+1
enddo
do nmvars
sele 1
use
sele 2
use
sele 3
use
do moremake with cname
flnew=dirr+"issu.dbf"
flnm="intr.dbf"
if file(flnew)
  run rename &flnew &flnm
endif
flnew=dirr+"issu.htm"
flnm="intr.htm"
if file(flnew)
  run rename &flnew &flnm
endif

run cd &coun
**run del *.dbf
run del head*.*
run del maps.shtml
run cd..
run copy cpy\*.* &coun
do contiflag

return



I generated about 2000 .shtml files using clipper, The FTP upload to the site
was one manual zipped file upload,  which was unzipped at the site. 
Here is an example of one .shtml file "afri.shtml" generated, with the center showing headlines which in those days was showing scrolling info from another free source of information.  Everything was coded in a computer with 1 MB memory access and Clipper 5.1.  I used DBXL in immediater mode to debug small prg files before putting them to clipper to compile and execute.

<Font color= "#000000"  face= "verdana" size= "2" >
<p>
<center>
<table border=0 cellspacing=0 cellpadding=0  width=100%>
<tr>
<td align="center" bgcolor="#0000CC"><font color= "#FFFFFF" size="+1"><b>
Africa</b>
</font></td>
</tr>
</table>
</center>
<P>
<b>Awakening</b> of a whole continent.<br>
Crippled from two centuries of slavery and a further century of exploitation, Africa is
at last joining the world as an equal.  North Africa, the craddle of civilization, is separated both
physically and culturally from the south, with the world's largest desert, the Sahara,
separating the two halves.  Ghana was one of the first countries to gain indepensence, whilst South
Africa is the richest but was dominated by white minority till a few years ago.
<center>
<table border="1" cellspacing=0 cellpadding=0 bgcolor="#99CCFF" width=100%>
<tr> <td align="center" width="20%"><font size="-1" ><b>World Today<br>
<a href="http://sensiworld.net/worldwire.shtml" target="_blank">Newswire</a><br>
<a href="http://sensiworld.net/photonews.shtml" target="_blank">Photo Stories </b></a>
</td>
<td align="center" valign="center" bgcolor="0033CC">
    <!--#include file="afrimb1.shtml" -->
</font></td>
<td align="center" width="20%"><font size="-1">
<A href="http://news3.newsindex.com/cgi-bin/processfreepage.cgi?query=world+africa+egypt+tanzania+zimbabwe+nigeria+zambia+angola+congo+wild+forest+fires+desert+kenya+nigeria+leone+libya+morocco+algeria+sudan+ethiopia+eritrea+chad+tanzania+mozambique+liberia+uganda+nile+zaire+sahara+&mode=any&BGCOLOR=FFFFCC&OWNER=SensiWorld+all+topics+Africa&LOGO=http://www.sensiworld.net/graphics/addesign01.gif&RETURN=http://www.sensiworld.net/afri/" target="_blank">
<b>More Africa News</b></a></td>
</tr>
</table>
</center>


A lot is possible and to me the use of RUN or RENAME and other DOS commands was all taken in its stride without a lot of fuss.  It is a pity that we have mega and gigabytes to play with, but are somehow bogged down in the intricacies of Windows to an unrealistic extent.
Even the multilingual problem or change is somehow frozen at ANSI level,  and reliance is on "codepages" more or less, with people are giving lip service to "Unicode"

Bopdji.

**--** **--** **--** **--** **--** **--** **--** **--** **--** **--** **--** **--** **--** **--**

Viktor

Viktor Szakáts

unread,
Feb 28, 2011, 7:08:19 PM2/28/11
to Harbour Users
Hi Bopdji,
[...]
>
> A lot is possible and to me the use of RUN or RENAME and other DOS commands
> was all taken in its stride without a lot of fuss.  It is a pity that we

FRENAME() was invented by the original authors of
Clipper, and it's available since 20 years. It makes
your complicated, not very resource efficient and
non-portable (MS-DOS specific) method of renaming
a file extremely simple. If you say we should still
rename a file by calling an MS-DOS command in 2011,
for me it's hard to grasp, and it could hardly be
justified as a driving force when forming Harbour's
future.

> have mega and gigabytes to play with, but are somehow bogged down in the
> intricacies of Windows to an unrealistic extent.

Harbour is not about Windows intricacies, its core APIs
don't contain anything Windows specific. HB_RUN()
is a fully portable solution to a fully universal problem
of _running another process_. I'm risking giving you a
heart attack, but Harbour also has a special API just
to run processes in even more fine tuned way:
HB_PROCESSRUN().
It's actually key functionality these days, just as it was
key functionality 30 years ago. Amongst others it helps
hbmk2 and hbide do its job. And no it won't be linked,
if you don't actually use it.

> Even the multilingual problem or change is somehow frozen at ANSI level,
> and reliance is on "codepages" more or less, with people are giving lip
> service to "Unicode"

You took an example of 'RUN RENAME' where you can
indeed check if the file was renamed (even though your
whole solution in non-portable, so it contradicts Harbour's
primary goal to be portable), but you still don't know why the
rename failed (if it failed), because you just have _no way
to read the errorlevel in pure dBase/Clipper_.

You may try to develop similar hacks for other problems,
but 1) it's a waste of time 2) they are hacks so they will
work under a limited set of conditions and they won't be
nearly as efficient as proper solutions.

Isn't this simpler, more stable, and portable to do this?

IF HB_RUN( "app.exe" ) != 0
? "app exe failed"
ENDIF

Or this (which is pure 20 year old Clipper5):

IF FRENAME( "this", "that" ) != 0
? "rename failed"
ENDIF

So while I accept your opinion that you don't need anything
more that dBase offered 25 years ago, it'd be hard to ask
all Harbourers to stop developing Harbour, just because we
reached dBase compatibility 5-6 years ago. It would hardly
be an ambitious goal.

You can however, use the subset you need without
having to deal with gigabytes of "bloat" _you_ don't need.
Others can use what they need.

BTW I'm hereby offering any user a dollar for every gigabytes
of bloat they can find in a Harbour application ;)

Viktor

Bopdji Shah

unread,
Feb 28, 2011, 8:58:58 PM2/28/11
to harbou...@googlegroups.com
The subject of the discussion is not about freezing Harbour at Clipper level, but how to use the STYLE of programming invented by dBase and Clipper.  I have to keep on bringing in the word dBase because it was Ashton Tate group which started the revolution, and Clipper was merely a late join in.

That programming style allowed use of multi word commands like SET TALK or APPEND FROM.  Notice the separate words?  Why did Harbour have to go for underscore command words such as HB_PROCESSRUN() is beyond my comprehension when words like HB PROCESS RUN would have been OK.  So dBase whilst sticking to C type usage made it more user friendly with multi words like INDEX ON  and many more.

I do not see Windows (whether Microsoft or X windows) as anything more than a practical interface. In dBase we had input command and we waited for user input and some file commands which instructed the file system to do something and Windows is no different except that it uses toys such as mouse and mouse movements.  I have personally implemented a DOS level "listview" type of interface in some programs and have had keyboard inputs to guide up and down the list.  I see the scroll bar as more elgant and more user friendly way, but keep the implementation of it and the usage of it simple. The DOS DIR gives a list of files and the Windows method also gives a list of files - keep it simple, so that the programmer can migrate and be comfortable with (x)Harbour.  Even when I knew how to implement a Listview control in DOS using PGup PGdn keys etc., when I changed to HTML, I welcomed the Javscript that lets me do it a bit more elegantly.  And I want to welcome Windows Listbox  with the same enthusiasm, but sadly I have not been able to welcome Minigui with as much enthusiasm as was expected of me, the application programmer.

So please understand -  I am not against change or innovation.  I am against complexity and requirement to change programming habits in a big way.  
If I was against inovation and new technology, I would still be programming in machine language of Z80 as I did in 1974!  But I accepted innovation to BASIC and to dBase and to  HTML and GUI and now to multi database Cloud and multinational Unicode divorced from 8 bit to 16 and 32 bit and at each step I was and remain ahead of the masses and will remain so.

You said: "Harbour is not about Windows intricacies, its core APIs

don't contain anything Windows specific." 

I disagree to the extent that Windows is not just a GUI interface, but it controls everything - files, networking, Internet access, storage of variables., etc., etc.   You have to look at some more innovative techniques of storage of variables to realize the enormous disadvantage of Windows method of storing data.  But we are dependent on it.


In fact, the first change I am urging is to go totally Unicode in all string and related functions and allow enough space as Microsoft Windows is still very leaky (memory leaks!).  Whether you choose 16 bit LE or 32 bit or go the Linux route of 8 bit UTF-8 is your choice - I would suggest for sanity and future expansion a 32 bit Unicode as the internal standard for Harbour - use it the same way as Microsoft interfaces to all different character formats  using the 16bit LE standard internally.  The change I am suggesting is fundamentally more innovative and sensible than migration in 1985 to Windows or X windows which was just a cosmetic makeover.  Then Harbour will be ready to migrate outside of Europe and Brazil.

**-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **-- **--


Viktor

do...@people.net.au

unread,
Feb 28, 2011, 10:33:38 PM2/28/11
to harbou...@googlegroups.com

"That programming style allowed use of multi word commands like SET TALK or APPEND FROM.  Notice the separate words?  Why did Harbour have to go for underscore command words such as HB_PROCESSRUN() is beyond my comprehension when words like HB PROCESS RUN would have been OK.  So dBase whilst sticking to C type usage made it more user friendly with multi words like INDEX ON  and many more."

SET TALK and APPEND FROM are commands whereas HB_PROCESSRUN() is a function (ans so cannot have spaces in its name).  You should realise that SET TALK and APPEND FROM commands are converted to functions by the pre-processor.  If you really want to you could enable the use of HB PROCESS RUN by using #xcommand but such an approach becomes less than desirable (in my opinion) when you have to pass a series of parameters.  SET TALK was easy because it only took one parameter - a logical - so you just had SET TALK ON or SET TALK OFF.  Your (and my) beloved dBase used both commands and functions because there are limits to the readability of commands in such circumstances and because functions allow return values.  But Harbour allows you to create a command version of any function you desire.



"You said: "Harbour is not about Windows intricacies, its core APIs
don't contain anything Windows specific." 

I disagree to the extent that Windows is not just a GUI interface, but it controls everything - files, networking, Internet access, storage of variables., etc., etc.   You have to look at some more innovative techniques of storage of variables to realize the enormous disadvantage of Windows method of storing data.  But we are dependent on it."

Harbour is Windows agnostic - which is why it runs across so many OSes and in character mode, character based windowed mode or full GUI mode.  That's both a real strength in that it gives you flexibility and transportability but also a problem in that you have to decide what sort of user interface you want and in many cases link in an additional library.  In my case I wrote an interface to GTK+.  The OS doesn't control how variables are stored - Harbour does.  You are going to want the OS to take care of the hardware level detail of internet access etc but Harbour gives you a fair range of appropriate tools should you wish to do IP sockets, send / receive files using FTP etc.

Viktor Szakáts

unread,
Mar 1, 2011, 4:45:46 AM3/1/11
to Harbour Users
Hi,

On Mar 1, 2:58 am, Bopdji Shah <bop...@gmail.com> wrote:
> The subject of the discussion is not about freezing Harbour at Clipper
> level, but how to use the STYLE of programming invented by dBase and
> Clipper.  I have to keep on bringing in the word dBase because it was Ashton
> Tate group which started the revolution, and Clipper was merely a late join
> in.

You can find my answer to that in my first reply. Such dBase
style commands can be add anytime by anyone, even locally
for yourself or provided as a 3rd party header for all users.
So far nobody needed it apparently, so no time was spent
on it.

> That programming style allowed use of multi word commands like SET TALK or
> APPEND FROM.  Notice the separate words?  Why did Harbour have to go for
> underscore command words such as HB_PROCESSRUN() is beyond my comprehension
> when words like HB PROCESS RUN would have been OK.  So dBase whilst sticking
> to C type usage made it more user friendly with multi words like INDEX ON
> and many more.

My personal opinion on commands is that they have several
drawbacks while I just cannot see much of the cons.

Cons:
Much more typing
No intuitive way to return values
Sometimes hard to remember parametrization
Not possible to combine them in a chain
No efficient way to morph the command based on input parameters
Inefficient (gets translated to functions internally by PP, many
times uses macro)
Harder to control what exact code gets generated.
Pros:
Maybe easier to remember for some users and in cases the command
has many optional parameters.

Your personal milage may vary, and also for some purposes commands
may suite better (for example defining GUI elements), for some others
it's less useful (file I/O) and for some purposes it's not even
possible
to use commands (math functions).

It may also be irrelevant from a technical perspective, but Clipper
departed from command based programming in the early nineties,
and I can see no other modern/living language which would have
endorsed the concept to any meaningful extent. In fact Harbour
(and other xbase dialects) is a rare example where commands are
still available as an option, which is good.

> I do not see Windows (whether Microsoft or X windows) as anything more than
> a practical interface. In dBase we had input command and we waited for user
> input and some file commands which instructed the file system to do
> something and Windows is no different except that it uses toys such as mouse
> and mouse movements.  I have personally implemented a DOS level "listview"
> type of interface in some programs and have had keyboard inputs to guide up
> and down the list.  I see the scroll bar as more elgant and more user
> friendly way, but keep the implementation of it and the usage of it simple.
> The DOS DIR gives a list of files and the Windows method also gives a list
> of files - keep it simple, so that the programmer can migrate and be
> comfortable with (x)Harbour.  Even when I knew how to implement a Listview
> control in DOS using PGup PGdn keys etc., when I changed to HTML, I welcomed
> the Javscript that lets me do it a bit more elegantly.  And I want to
> welcome Windows Listbox  with the same enthusiasm, but sadly I have not been
> able to welcome Minigui with as much enthusiasm as was expected of me, the
> application programmer.

Windows and XWindow are two different things, first is an OS with a
GUI,
second is a GUI engine. Anyways there much more into these OSes
than the GUI.

BTW, MINIGUI uses commands, it was one of its primary goals.

> So please understand -  I am not against change or innovation.  I am against
> complexity and requirement to change programming habits in a big way.
> If I was against inovation and new technology, I would still be programming
> in machine language of Z80 as I did in 1974!  But I accepted innovation to
> BASIC and to dBase and to  HTML and GUI and now to multi database Cloud and
> multinational Unicode divorced from 8 bit to 16 and 32 bit and at each step
> I was and remain ahead of the masses and will remain so.
>
> You said: *"Harbour is not about Windows intricacies, its core APIs
> don't contain anything Windows specific." *
> I disagree to the extent that Windows is not just a GUI interface, but it
> controls everything - files, networking, Internet access, storage of
> variables., etc., etc.   You have to look at some more innovative techniques
> of storage of variables to realize the enormous disadvantage of Windows
> method of storing data.  But we are dependent on it.

All this is irrelevant because these Windows specific
features are all abstracted and presented to you via
portable interfaces, so they can work the same way
also on a Linux system f.e.. Only if you use hbwin library,
you will meet with Windows specific "intricacies".

> In fact, the first change I am urging is to go totally Unicode in all string
> and related functions and allow enough space as Microsoft Windows is still
> very leaky (memory leaks!).  Whether you choose 16 bit LE or 32 bit or go
> the Linux route of 8 bit UTF-8 is your choice - I would suggest for sanity
> and future expansion a 32 bit Unicode as the internal standard for Harbour -
> use it the same way as Microsoft interfaces to all different character
> formats  using the 16bit LE standard internally.  The change I am suggesting
> is fundamentally more innovative and sensible than migration in 1985 to
> Windows or X windows which was just a cosmetic makeover.  Then Harbour will
> be ready to migrate outside of Europe and Brazil.

We're planning to add internal UNICODE support.
There has been a lot done in this area already.

Viktor

Bopdji Shah

unread,
Mar 1, 2011, 2:47:25 PM3/1/11
to harbou...@googlegroups.com
Rather than create more contraversy, I will simply say that I do not agree with quite a few things you say.  In particular harbour does not decide how variables are stored.  It is the C language which decides (in its own peculiar way) and Microsoft and Linux are both C, so it is ultimately these operating systems which decides in the way C language wants it.

Some of the C language compilers have tried to get around the obvious, well documented and oft criticzed quircks of C and C++.  I could elaborate, but I will let you find for yourself.   To me C and C++ is more like a burden we have to carry to be able to live in the computing world and have the so called advantage of "interOS operability" and simulate the same crashes in three different operating systems, buying more and more memory doing proportionately less and less.

BTW creating "headers if I want", is definitely NOT for the application programmer.  If I know C well then I would be better off programming in C++ and forget harbour, and If do not know it well, I certainly don't want to be burdened with a million error messages before my module is usable.   There is a plethora of C and C++ free libraries.

If you are serious about Unicode, I would suggest (after 6 months of research) that QT is the route to go and wxWidgets is the next best.   If you are REALLY serious, start with changing every string related C module and bring in calls to what is available in these compiler/libraries, and make sure you provide enough SPACE everywhere including in the field sizes and numbers.   Yes, the compiled sizes will increase and so will database sizes, but nowhere near what it would happen  with with a monster named .net.   In this effort Microsoft would be more tolerant of your mistakes and Linux might not be as tolerant.  And just as the die-hard English speaking world had to forget ASCII and think ANSI, the new world would require a deliberate effort to forget ANSI and codepages and think Unicode.

All the best to you and you efforts.  I will continue watching in the sidelines.  I am of Indian origin and our teaching and learning methods were based not on praise but heavily on criticism even for the smallest errors.



Viktor

Bopdji Shah

unread,
Mar 1, 2011, 3:37:33 PM3/1/11
to harbou...@googlegroups.com
Victor:

You might find this article useful.  It tends to confirm what I said above regarding the infrastructure you are working with.

http://c0de517e.blogspot.com/2011/02/surviving-c.html

Viktor Szakáts

unread,
Mar 1, 2011, 3:46:54 PM3/1/11
to Harbour Users
On Mar 1, 8:47 pm, Bopdji Shah <bop...@gmail.com> wrote:
> Rather than create more contraversy, I will simply say that I do not agree
> with quite a few things you say.  In particular harbour does not decide how
> variables are stored.  It is the C language which decides (in its own
> peculiar way) and Microsoft and Linux are both C, so it is ultimately these
> operating systems which decides in the way C language wants it.

I don't understand what your concern is, sorry. Nor
do I understand what you mean by "how variables are
stored", and even less so how such low-level technical
detail is connected to this thread, or the way Harbour
is developed or its future planned.

Maybe you should suggest a good way to store data,
if that concerns you.

> Some of the C language compilers have tried to get around the obvious, well
> documented and oft criticzed quircks of C and C++.  I could elaborate, but I
> will let you find for yourself.   To me C and C++ is more like a burden we
> have to carry to be able to live in the computing world and have the so
> called advantage of "interOS operability" and simulate the same crashes in
> three different operating systems, buying more and more memory doing
> proportionately less and less.

Is your problem that Harbour is written in C?

> BTW creating "headers if I want", is definitely NOT for the application
> programmer.  If I know C well then I would be better off programming in C++
> and forget harbour, and If do not know it well, I certainly don't want to be
> burdened with a million error messages before my module is usable.   There
> is a plethora of C and C++ free libraries.

It has nothing to do with C. I was talking about Harbour/Clipper
.ch header files where all ("old style") commands are defined.

Then you're asking others to do the job of development and
testing for your requested feature, which is fine, but then you
have to keep waiting until someone does that.

> If you are serious about Unicode, I would suggest (after 6 months of
> research) that QT is the route to go and wxWidgets is the next best.   If
> you are REALLY serious, start with changing every string related C module
> and bring in calls to what is available in these compiler/libraries, and
> make sure you provide enough SPACE everywhere including in the field sizes
> and numbers.   Yes, the compiled sizes will increase and so will database
> sizes, but nowhere near what it would happen  with with a monster named
> .net.   In this effort Microsoft would be more tolerant of your mistakes and
> Linux might not be as tolerant.  And just as the die-hard English speaking
> world had to forget ASCII and think ANSI, the new world would require a
> deliberate effort to *forget ANSI and codepages and think Unicode.*

You're mixing a GUI with UNICODE with storage space and
OSes and 3rd party dev tools. I'm confused what we're talking
about now. Harbour will eventually get UNICODE support regardless
of underlying OS and regardless of any GUI systems above it.

> All the best to you and you efforts.  I will continue watching in the
> sidelines.  I am of Indian origin and our teaching and learning methods were
> based not on praise but heavily on criticism even for the smallest errors.

Thank you for your input!

Viktor

Pritpal Bedi

unread,
Mar 1, 2011, 4:35:24 PM3/1/11
to Harbour Users
Hello Mr Bopdji Shah

> All the best to you and you efforts.  I will continue watching in the
> sidelines.  I am of Indian origin and our teaching and learning methods were
> based not on praise but heavily on criticism even for the smallest errors.

Are you saying that Indians do not have
aptitude for "praise" even if it praise worthy ?
Are you saying that Indians can criticise only ?

Come on Mr Bopdji, do not put every Indian
on a ride. A healthy criticism is always welcome
but not when it tends to be a crap without
understanding the underlying concepts first.

Pritpal Bedi

Viktor Szakáts

unread,
Mar 1, 2011, 9:40:06 PM3/1/11
to Harbour Users
Hi Bopdji,
Thank you, I see the article is about bashing C++, which
is perfect with me, but please note that Harbour is written
in _ANSI C_. It's another basic rule of the project, and
we chose it over C++ for good reasons. If you listed the
article to prove that "macro system on top of a language"
is wrong concept, please note that Harbour's macro system
and C++'s are pretty different animals and not much to
do with each other, so any C++ arguments can very
hardly be applied to Harbour.

If you have a problem that the sacred legacy dbase
commands are implemented in preprocessor stage in
Harbour/Clipper, well, that's pretty much late to discuss,
because the decision has been made 20 years ago, not
even by us, but by Nantucket/CA, even though I don't
remember anybody have ever disputed this decision
from the Harbour community. It gives great flexibility.
Harbour even extended this flexibility.

If there is any part I can agree with is that the Harbour
OOP syntax is based on PP rules instead of being "native",
though if I don't tell you about it, you would have hardly
noticed it.

Maybe you should take a look at what we're talking
about it, before continuing this thread.
You can start with:
include/std.ch

Viktor

Bopdji Shah

unread,
Mar 1, 2011, 9:53:52 PM3/1/11
to harbou...@googlegroups.com
From a lot of experience in learning and teaching Indian style and western style, It is obvious that the Indian student goes towards perfection much more easily from criticism than unnecessary praise.  It is the relative difference in methods of teaching and learning and has nothing to do with superiority or inferiority of a particular method.


--
Reply all
Reply to author
Forward
0 new messages