The journey begins?

1,653 views
Skip to first unread message

Martin Fears

unread,
Nov 22, 2024, 3:39:41 PM11/22/24
to Harbour Users
First timer here - hello all!

I was a Clipper programmer back in the late 80's early 90's and although my career stayed in IT I moved on (BA / PM) so I've not been hands-on technical for a long time.  Now I'm retired ....

Back in the day, in my spare time, I wrote a very bespoke Clipper application for personal use and over the years have added enhancements.  I'm the only user, but that could change.  It's made up of ~23k lines of code, several DBFs and many NTXs.  I use Clipper v5.2 but also use the Clipper Extend and Net-Lib 6 libraries and Blinker 3.3

Now, I'm seeking the path of least resistance to migrate this to run in Win32 & Win64 architecture.  My recent laptop won't permit a 32bit O/S to be installed so I went down the VM route.  But given this issue will only get worse in years to come, I need to find the proper solution, aka get my EXE to run on a 64 bit (Windows) PC.

Is Harbour my answer?  How different will I find Harbour.  I find the Clipper coding a bit like riding a bike - I don't do it very often (a few days every couple of years) so I wobble about a bit but soon find my balance.  Will a transition to Harbour be a very different kind of bike where there will be a lot of re-learning required of new tricks?

Any experiences and (sensible) advice would be most welcome.

cod...@outlook.com

unread,
Nov 23, 2024, 3:34:04 AM11/23/24
to Harbour Users

Hi Martin.

Yes, Harbour *is* your answer. Your application will work on your laptop with Windows 64 bit. It is good to say that Harbour can be used on Linux and some other OS. Harbour is 100% compatible with Clipper.

Your code will work in Harbour almost same as it is now. May be you will need to do some small, small  changes in some particular parts of your code, if any. You will see it when compiling and linking existing application.

Main effort will be to find Harbour counterparts for library functions you used. Also may be you will do some changes in printing parts of your application, but it depends on how you realized printing in existing application.

Best place to start is to visit next link:

https://github.com/harbour/core

Also, great source of knowledge is this Harbour user forum. Just search and you will find answer on most of your questions.

First you must install Harbour on your laptop. You can do it in two ways (see section "3.How to Get" in upper link):

1.Download and install binary version of Harbour. This means that you will not bother with building Harbour binaries on your laptop but use already prepared (binaries-windows).

2.Download Harbour source and build Harbour on your laptop. If you decide to build Harbour it is important to choose compiler you prefer to use. See section with lucky number "13.Supported Platforms and C Compilers"  J .  

Search this forum to see experiences and opinions on what way of Harbour installing to use.

You can visit next interesting links:

https://kresin.ru/en/hrbfaq.html

https://harbour.wiki/index.asp?page=PublicArticles&mode=show&id=190129210053&sig=7790451073#section_8387579888

https://harbour.github.io/doc/

https://www.fivetechsoft.com/harbour-docs/harbour.html

https://harbour.wiki/

http://www.elektrosoft.it/tutorials.asp

There are several other good links on interenet, you will find it reading and searching this forum.

At the end: When using Harbour you will replace your .LNK project file with Harbor .HBP file.

Best Regards,

Simo.

Auge & Ohr

unread,
Nov 24, 2024, 9:29:01 AM11/24/24
to Harbour Users
hi,

i recommend to get a "full-packet" with Compiler/Linker/LIBs/Ide and many Samples "out-of-the-box" like HMG

greetings JImmy

fdaniele

unread,
Nov 25, 2024, 2:21:48 AM11/25/24
to Harbour Users
if you wont only start your program see 

J Muller

unread,
Nov 25, 2024, 7:17:06 AM11/25/24
to Harbour Users
I'd write a matrix of advantages/disadvantages of the different options. 

1. Upgrading to harbour: disadvantages: exotic, not guaranteed to exist in future but   advantages: very comparable language. small dbfs, indexes and files are likely to be usable in the long run. 
2. Upgrading to nocode type of environment: advantages cloudy with backups etc., based more on design of backend. disadvantages: not guaranteed to exist in future. 
3. Upgrading to other fat-client: MS-Access, python+sqlite, or any of the other candidates. 

harbour may or may not be your best solution. 
J.

Martin Fears

unread,
Nov 25, 2024, 10:42:22 AM11/25/24
to Harbour Users
Hi and thanks for your suggestion.

I did try this (similar DOS BOX) a few years back.  It would appear these types of DOS emulators are throttled (slowed down) to enable old DOS games to be playable on faster CPUs.  My app ran, but at a snail's pace and was unusable .....

Martin Fears

unread,
Nov 25, 2024, 10:50:28 AM11/25/24
to Harbour Users
Thanks

By "path of least resistance" I was suggest as little as possible rewriting of code.  For this, the best case would be zero code change, a small tweak to my RMK & LNK files and out pops a new EXE that runs on a Win64 platform.

The are a lot of man-days (years) invested in the code so rewriting from scratch in MS-Access Python+SQLite would be a huge job - similarly no-code is going to require a massive time commitment.

If I can install Harbour (3.4.4 or 3.5 ?) and then simply change the compile and link scripts, that's going to be my only choice.

Is there "conversion from Clipper" or "Harbour for Dummies" documentation you could point me to?

Daniele Campagna

unread,
Nov 25, 2024, 11:43:24 AM11/25/24
to harbou...@googlegroups.com
Il 25/11/2024 16:42, Martin Fears ha scritto:
> Hi and thanks for your suggestion.
>
> I did try this (similar DOS BOX) a few years back.  It would appear
> these types of DOS emulators are throttled (slowed down) to enable old
> DOS games to be playable on faster CPUs.  My app ran, but at a snail's
> pace and was unusable .....
>
Not all DOS emulators have the same goals. Some are optimized for games.
Vdosplus is fast and reliable, and is not intended for gamers.

But, DOS-Clipper apart, my hint is to switch to Harbour.

Harbour will allow you to recompile your Clipper program and run it 32
or 64 bit. Then you'll have the choice if continuing to work "as usual"
with Clipper syntax and console applications, or switch to GUI.

Harbour + some GUI library can do it. But even if used as Clipper,
Harbur has a lot of empowerments. It can use long filenames, extends the
maximum size of files and records, the size of arrays is limited by the
memory of the host, and we have now more than 640Kb of RAM...

You'll find replacements for Clipper Tools, Nanforum Toolkit, etc.
Harbour supports RDD technology, so you can use NTX or CDX indexes.

Harbour offers the possibility to link c modules as Clipper did. It can
load .COM objects. Supports OLE. You can call Windows applications (or
API calls) from inside your program. You can access the Internet,
navigate, download a page, consume web services.

You can write a cgi program that runs under a web server.

You have true thread management. You can

Well, I think I gave you the idea. Harbour is very powerful and
flexible. Oh and it's FAST. Against some .NET gigantic bloatwares it
cannot even be compared. In another league. :-) (A Cgi program made with
Harbour is 2 or 3 Mb in size and under Linux is blazingly fast, ah yes,
Harbour runs under Linux, too)

Only problem: if you used some arcane libraries in your program and you
don't have the sources, that's a problem. Go back to the vdosPlus
section or write/find the replacements for that library. :-)

Seriously, you just need a free C compiler. The linker and make utility
are included. Download the binaries of Harbour and you are halfway.

Let us know...

Dan


Maurício Faria

unread,
Nov 25, 2024, 1:21:45 PM11/25/24
to harbou...@googlegroups.com
Hi.
Try this:

https://www.kresin.ru/en/hrbsteps.html

[[]] Maurício Faria

Angel Pais

unread,
Nov 25, 2024, 2:52:57 PM11/25/24
to harbou...@googlegroups.com
Advice: At the beginning of your main.prg you must issue: SetMode(25,80)
If it's a standard project it should work
The rest is impossible to know without seeing your project and/or more details about it.

That  Net-Lib 6 library most probably will have to be rewritten in Harbour or emulated somehow

Regards
Angel Pais

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/84eb1aed-49c7-42df-98a1-0c25f651aa46%40gmail.com.

Maurício Faria

unread,
Nov 26, 2024, 2:39:25 AM11/26/24
to harbou...@googlegroups.com
Hi.
Almost zero work to convert Clipper code.
You will have to learn a bit about how it works, but it was built by clipper guys, so, people like you.
Try the nightly build install.
https://sourceforge.net/projects/harbour-project/files/binaries-windows/nightly/harbour-nightly-win.exe/download
It is a bit dated but will do the job for you to start.
Any problem you can back here and many people will try to help.



Em 22/11/2024 10:15, Martin Fears escreveu:
--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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.

fdaniele

unread,
Nov 26, 2024, 12:41:47 PM11/26/24
to Harbour Users

If you want to convert your work, take a look to minigui extend, is semi-ready and a lot of examples


Daniele

Martin Fears

unread,
Dec 1, 2024, 9:08:57 AM12/1/24
to Harbour Users
Some progress to report: 
I have converted my library to "mylib.a" and created a "myproject.hbp" that contains all my *.prg files and a link to mylib.a

As Angel predicted earlier my (27 used) NetLib functions are coming back unresolved.  It would be great if someone had a 3rd party library for these.  I can write some of them out of my code but some are quite key to my project and will need a replacement / alternative to be found.  Below are the ten most critical and an outline of their purpose (extracted from NL6.NG).  If there are Harbour similar functions I'd be grateful to be told.

Many thanks

Martin

N_CODELVL() 
Determine if a file is encrypted

N_DECODE() 
Decrypt a file based on the current SETKEY

N_ENCODE() 
Encrypt a file based on the current SETKEY

N_ENCODENEW() 
Direct that all new files be encrypted with current key

N_SETKEY() Set the current encryption key
N_FATTRGET() Get the current setting of file attribute(s)
N_FATTRSET() 
Set file attribute(s)

N_FDRIVE() 
Get the drive letter portion of a filespec

N_READONLY() 
Set read-only mode for subsequent USE

N_READY() 
Ready a program for network operation


Martin Fears

unread,
Dec 5, 2024, 9:13:38 AM12/5/24
to Harbour Users
Making progress but help needed ....
I'm getting the followng problems at the moment.

1/ I think I have Clipper Tools (hbct.hbc) in my proj.hbp file but several CT functions are coming up as unresolved: e.g.
DISKFREE() DISKTOTAL() GETCOUNTRY() GETSHARE() NUMBUFFERS() NUMFILES() STACKFREE()
Should these functions be found in hbct.hbc (and I'm doing it wrong) or are these functions absent from hbct.hbc (and I'm doing it right)?
In my proj.hbp I have the line "\Harbour\hb32\contrib\hbct\hbct.hbc"  should it be "hbp" ?

2/ I'm still very new to Harbour and am yet to understand the differences between .hbp vs .hbc vs .hbx build files?

3/ Having created my own "mylib.a" file and referenced in my proj.hbp file as \harbour\hb32\lib\TSA\lib\win\mingw\mylib.a I'm getting linker errors for functions with the same name that are in both mylib.a AND myproj.prg.  Under Clipper if the same name function existed in the library it was ignored such that the "local" (in the project) was used and no duplicate issues came about.  Is there a hbmk2 switch I've yet to discover that will make it behave like CLIPPER / BLINKER / RMAKE did (does).

I feel my first myproj.exe created with Harbour is now close ....

Francesco Perillo

unread,
Dec 5, 2024, 10:57:49 AM12/5/24
to harbou...@googlegroups.com
3. I'm not aware of any switch

2. Hbp is for compiling, hbc is for linking, listing all dependencies you need

1. Look at hbct source code if those functions are present

Daniele Campagna

unread,
Dec 5, 2024, 11:34:22 AM12/5/24
to harbou...@googlegroups.com

Hi,

the line \Harbour\hb32\contrib\hbct\hbct.hbc in your .hbp file is correct. It instructs the linker to use the definitions in hbct.hbc to link the hbct library.

I confirm that AFAIK duplicate functions name are not allowed, also when in a library, and that in Clipper the second one prevails on the previous with no errors.

I seem to remember anyway that once I had two libraries with a function with the same name and the solution was to change the order of libraries in the link script, so that the "right" function was called. No errors anyway was given, I only  noticed that the function was behaving strangely... it was the "wrong" one.

Anyway, post your .hbp file here if the compilation fails.

HTH

cod...@outlook.com

unread,
Dec 5, 2024, 11:53:16 AM12/5/24
to Harbour Users
Hi.

3/

As I remember Blinker allows to have duplicate function names when processing .LNK file. I had such situation in CLipper times. I am not sure, in such situation (several functions with same name) the winner was last one in list of PRGs in .LNK file. It was not considered as error, just warning.

When I start to use Harbour, it was not allowed. I had to rename functions, or to delete redundant functions with same name.

I do not put mylib.a inside \harbour folder. My lib PRGs I keep in separate folder, say on D disk in \Myfunc, and in that folder I make mylib.a Then in main applicaton .HBP I only put next lines:

-L\Myfunc\

-lmylib

 

In this way I have less job when installing new version of Harbour. Do not need to think what my libs I must to refresh in \harbour folder.

Regards,
Simo.

cod...@outlook.com

unread,
Dec 5, 2024, 1:11:16 PM12/5/24
to Harbour Users
Hi.

Somewhere I found that DISKFREE and DISKTOTAL are replaced with HB_DISKSPACE() function, see next link:


Regards,
Simo.

Klas Engwall

unread,
Dec 5, 2024, 1:30:46 PM12/5/24
to harbou...@googlegroups.com
Hi Martin,

> Making progress but help needed ....
> I'm getting the followng problems at the moment.
>
> 1/ I think I have Clipper Tools (/hbct.hbc/) in my /proj.hbp/ file but
> several CT functions are coming up as unresolved: e.g.
> *DISKFREE() DISKTOTAL() GETCOUNTRY() GETSHARE() NUMBUFFERS() NUMFILES()
> STACKFREE()*
> Should these functions be found in /hbct.hbc/ (and I'm doing it wrong)
> or are these functions absent from /hbct.hbc/ (and I'm doing it right)?
> In my /proj.hbp/ I have the line
> "/\Harbour\hb32\contrib\hbct\hbct.hbc/"  should it be "hbp" ?

Not all CT functiona exist in the hbct library, simply because they make
no sense in modern computers. Remove the ones you relly don't need from
your source code, and the list of unresolved externals should get a lot
shorter.

> 2/ I'm still very new to Harbour and am yet to understand the
> differences between .hbp vs .hbc vs .hbx build files?
>
> 3/ Having created my own "/mylib.a/" file and referenced in my
> /proj.hbp/ file as /\harbour\hb32\lib\TSA\lib\win\mingw\mylib.a/ I'm
> getting linker errors for functions with the same name that are in both
> /mylib.a/ AND /myproj.prg/.  Under Clipper if the same name function
> existed in the library it was ignored such that the "local" (in the
> project) was used and no duplicate issues came about.  Is there a hbmk2
> switch I've yet to discover that will make it behave like CLIPPER /
> BLINKER / RMAKE did (does).

As Daniele said, allowing different functions with the same name in
several places is inviting errors. Rename the functions that are your
own to for example "mf_something()". There is a reason why the MinGW
linker refuses to cooperate.

Regards,
Klas

Francesco Perillo

unread,
Dec 5, 2024, 1:57:59 PM12/5/24
to harbou...@googlegroups.com

Shameless plug... have a look at this blog series I wrote years ago...
http://www.mozzarellaincarrozza.it/harbour/converting-a-clipper-87-application-to-harbour/

Start from A Christmas gift


--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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.

Auge & Ohr

unread,
Dec 5, 2024, 4:54:30 PM12/5/24
to Harbour Users
hi,

when have dupe function i use this in my HBMK.HBM File
------
DUALGRID.HBC
-w1 -es2  -ldflag=-FORCE:MULTIPLE
------

Cotswold GB

unread,
Dec 6, 2024, 9:32:06 AM12/6/24
to Harbour Users
Hi Martin, I came here from Clipper87 and needing graphical applications and as only creating database software spent from 1999 in Access. From A97, A2000, A2010 and now A2019 (as well as Harbour! ) just to keep the mind working.
So totally Windows  and have to say found it a huge curve to put something together in Harbour from my C87 programming memory. Mainly that I needed to know so much particularly as Harbour is maybe more Linux than MS-DOS. Plus the language is slightly different. Way more powerful but different here  and there. I don't think that there's much you can't do in Harbour. I've an A4 clip file full of Harbour stuff as well  as much on disk. One thing which is good, is that everyone was and are always most helpful on this forum. 

To help such as yourself and put something back.  I posted an example Harbour application for new users which I think maybe more help than picking up bits of code here and there.   I'm well retired now so am happy to pass this on as I'm unlikely to create systems for sale that would need support. (I am thinking about posting some of my Access software for steel fabricators onto GITHUB) 

If you are interested the application is at :           https://github.com/CotswoldWG/Harbour-Programming-Examples

It is a terminal program example with the main example screen a basic/simple address file. Something that is in just about all software. 

Maybe it will give you a little help? I feel that if I'd dropped across something like that it would have maybe saved me some time, I've documented it through the code. 
I'll need to do some Harbour graphical software next year but haven't quite decided which fork to go down, so to speak.

Regards, Will

Martin Fears

unread,
Dec 11, 2024, 2:34:20 PM12/11/24
to Harbour Users
Okay - I have my first EXE running !! :-)  Whoo-hoo ....
With myproj.hbp containing "-d" I'm able to invoke de-bugging with ALTD() and/or [Alt]+[D] - great !
However, there are a couple of "enhancements" to the debugger I would like to make.
1/  SETMODE(50,80)  To make better use of visible screen available to see more code and variables, etc. on view.
2/  SET DATE BRITISH  As my data works with many dates, this would make readability for me easier.
3/  SET CENTURY ON   Also to aid quick and simple date data reading with debugging for my benefit.

I'm still very new to Harbour, but getting to grips.  Being able to enhance the debug screen/facility with the above would help my Harbour relationship grow better.

Please can someone advise [in beginners steps] how I can achieve this?
Is there some source code somewhere I can simply edit and re-compile & link?
I did do a search on this site & Google but could not find anything that looked similar to my needs.
Many thanks ....

Eric Lendvai

unread,
Dec 12, 2024, 2:13:51 AM12/12/24
to Harbour Users
Hello Martin,

You may want to checkout some the articles at https://harbour.wiki/index.asp?page=PublicArticles
I use VSCode which include a pretty good Harbour Debugger. There is an article about how to set this up. 

If you are ready for some more advanced examples:
DataWharf is a Harbour web based app had uses Postgres.
The Webview binding can allow you to use HTML/CSS/JavaScript and Harbour together for Desktop apps.

Martin Fears

unread,
Dec 16, 2024, 8:09:45 AM12/16/24
to Harbour Users
Thanks Eric, but I'm happy with the standard debug tool I've been using for 30+ years (old dog, new tricks, scenario).
I just want to make a couple of very minor tweaks to improve the way it works for me.  I really don't want (or need) to go down a new debugger route.

I'm sure it's possible because when I revert to my old Clipper config/environment and RMAKE the same code, the debugger opens with dates in "dd/mm/yyyy" format as I wish and it displays in 50,80 display mode.  So I must have done it 30 years ago and never touched it since.  Now, I'm migrating to Harbour, I've compiled and linked DBU but where do I go (& how) to tweak the debugger config to work as I wish in Harbour?

I thought it maybe CLD related (although I don't debug by launching CLD myProg in my old Clipper environment)

Am I asking the impossible?

Tim J

unread,
Dec 16, 2024, 11:01:50 AM12/16/24
to Harbour Users
Hi Martin,
You should be able to put that code in your opening PRG file.
SETMODE(50, 80)  // I do this all the time, and the debugger shows it this way
SET DATE BRITISH  // Haven't used this, but have used SET DATE FORMAT
SET CENTURY ON // I also use this regularly, and the debugger respects it.

If they are set in you app, the debugger shows it.

Martin Fears

unread,
Dec 16, 2024, 12:44:49 PM12/16/24
to Harbour Users
Hmmmm, not so for me.

My app code opens with:
SETMODE( 25,80 )
SET( _SET_DATEFORMAT, "DD/MM/YYYY" )

When in dev mode (ie compiled with /b in Clipper or -b in Harbour) the [ALT]+[D] debug screen in Clipper changes to 50,80 and then reverts back to 25,80 when I go back to the running app.
Identical code when compiled and linked with standard Harbour - [ALT]+[D] stays in 25,80 and also uses a date format of yyyy-mm-dd

Must be a way ....

One other small but annoying issue - in Clipper, pressing  [ALT]+[D] at a wait-state immediately invokes the debugger screen but in Harbour,  [ALT]+[D] remains in the application and only switches to the debugger after I press another key.  This extra key press is KEYBOARD captured by the application, so the debugger invokes, but on the next line of code after the wait-state.  ALTD() in the code is fine.  What's that all about? (and what can I do to fix?)

CV

unread,
Dec 20, 2024, 9:28:38 AM12/20/24
to Harbour Users
Hi Martin

One simple solution should be adding this piece of code in any of your .prg files:

---
*
Init Procedure BasicSets()
*========================

SET CENTURY ON
SET DATE FORMAT to "dd-mm-yyyy"
setmode(25, 80)
cls

return
---

this will be run once at the very beginning of your application, so you can get the app window with the settings of your choice (add any other code you need there).

Regards,
--
Claudio Voskian
Buenos Aires - Argentina

Martin Fears

unread,
Dec 26, 2024, 3:59:26 PM12/26/24
to Harbour Users
No joy :-(

Yes that INIT PROC runs first and my application date format is "dd-mm-yyyy" and screen display mode is 25,80

BUT the debugger is still showing dates in "yyyy-mm-dd" format and I want the debugger to switch to 50,80 so I can see more rows of code/variables/data etc.

Where / what is the source code for the debugger as these setting must be in there somewhere and not inherited from the running application ....

Martin Fears

unread,
Dec 26, 2024, 4:17:30 PM12/26/24
to Harbour Users
I know printer with Clipper / Harbour is a well trodden path (I've read a lot of threads)

But I'm getting a fail with Win_PrintFileRaw()  - but it does return 1 = success??
O/S = Windows 10 32bit
Harbour = v3.2
Printer = HP Color Laser Jet Enterprise M552 (RAW enabled) This is configured as a Network printer, not USB but Win_PrinterGetDefault() finds it ok.
Here's my code:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                                            FUNCTION Test()
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
LOCAL nResult
LOCAL cFileName := "TSAprint.prn"

CLS
SET PRINTER TO &cFileName   // also tried as ( cFileName )
SET DEVICE TO PRINTER
SET PRINTER ON
QQOUT( P_CODES[P_RESET][3] )      // master reset = CHR(27)+'E'
@ PROW(),PCOL() SAY "HERE!"
@ 10,10 SAY "Win_PrinterGetDefault(): " + Win_PrinterGetDefault()
@ 11,10 SAY "trying a test print"
@ 12,10 SAY Chr( 12 )
//EJECT   // sends a CHR(12) to the printer?
SET DEVICE TO SCREEN
SET PRINTER TO
nResult := Win_PrintFileRaw( Win_PrinterGetDefault() , cFileName )
@ 13,10 SAY nResult
INKEY(0)

RETURN NIL

The Print Queue flashes up the file name, I hear the printer initialise a few seconds later, but no toner hits the paper.  I can open up the TSAprint.prn file with Notepad and that displays per expected outputs in the code and will print fine.

I've tried "EJECT", I've tried CHR(12) - it just seems to be missing something to release the SPOOLER to the PRINTER - I've searched the web but can find no clues.

Please, someone put me out of my misery ....
(I've spent hours trawling the internet for a solution to this)

Maurizio la Cecilia

unread,
Dec 26, 2024, 4:25:54 PM12/26/24
to harbou...@googlegroups.com


Hi Martin,
you'll find the main debugger source at:

https://github.com/harbour/core/blob/master/src%2Fdebug%2Fdebugger.prg

You can try modifying DEBUGGER_MAXROW and DEBUGGER_MAXCOL ( at rows 78-79) recompile Harbour and hope that the further display is relative to this constants.


Don Lowenstein

unread,
Dec 27, 2024, 4:08:23 AM12/27/24
to Harbour Users
Martin,

To set the screen size for the debugger, set a breakpoint and then change the height properties of the debugger window to your value ( change both the buffer and window size ).    Click "OK"

Next time the debugger hits a break point the "saved" size will be used.

I'm not sure about changing the date format for the debugger display.


From: harbou...@googlegroups.com <harbou...@googlegroups.com> on behalf of Martin Fears <martin.f...@gmail.com>
Sent: Thursday, December 26, 2024 2:59 PM
To: Harbour Users <harbou...@googlegroups.com>
Subject: Re: [harbour-users] The journey begins?
 
GRAPHUS
Warning: The sender harbour-users@googlegroups​.com might be a spam sender.
powered by Graphus®
1/  SETMODE( 50,80)  To make better use of visible screen available to see more code and variables, etc. on view.

Martin Fears

unread,
Dec 27, 2024, 6:26:00 PM12/27/24
to Harbour Users
The Win_PrintFileRaw() FAIL I'm unable to resolve is starting to wear me down ....
I've attached my printer screen-snips to see if someone can spot why ...
First attachment is the TSAprint.prn file the code creates - all as expected
Second attachment shows my TSAprint.prn file hitting the queue - as expected
Third attachment shows the printer properties and the port detail confirming RAW is selected
Here's my code again with some added error-trapping, but it always runs clan thru to the INKEY(0)
Why no action on the toner front?
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                                            FUNCTION Test()
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
LOCAL nResult, 
LOCAL cFileName := "TSAprint.prn"
nResult := Win_PrinterStatus( Win_PrinterGetDefault() )
IF nResult = 0                       // ZERO IS ALL GOOD
   SET PRINTER TO &cFileName         // ALSO TRIED ( cFileName )

   SET DEVICE TO PRINTER
   SET PRINTER ON
   QQOUT( P_CODES[P_RESET][3] )      // master reset ESC+E
   @ PROW(),PCOL() SAY "PRINT HEAD IS HERE!"

   @ 10,10 SAY "Win_PrinterGetDefault(): " + Win_PrinterGetDefault()
   @ 11,10 SAY "trying a test print"
   @ 12,10 SAY CHR( 26 )             // CHR( 26 ) IS EOF MARKER
   //@ 12,10 SAY CHR( 12 )           // CHR( 12 ) IS FORM-FEED
   //EJECT                           // same as CHR( 12 ) ??

   SET DEVICE TO SCREEN
   SET PRINTER TO
   nResult := Win_PrintFileRaw( Win_PrinterGetDefault() , cFileName )
   IF nResult <> 1
      ALERT( "PRINT FAIL: Win_PrintFileRaw() returned " + XtoS( nResult ) )
   ENDIF
ELSE
   ALERT( "PRINT FAIL: Win_PrintStatus() returned " + XtoS( nResult ) )
ENDIF
INKEY(0)
RETURN NIL

HP M552 printer port settings.JPG
TSAprint.prn
TSA (Harbour) print queue file.JPG

Daniele Campagna

unread,
Dec 28, 2024, 4:42:03 AM12/28/24
to harbou...@googlegroups.com

Are you sure your printer accepts ESC codes? In other words, can it print outside Windows ?

Just an idea...

Dan

Martin Fears

unread,
Dec 28, 2024, 8:11:18 AM12/28/24
to Harbour Users
Yes, I'm sure ....
I've been using this printer to print my Clipper app reports having it set up in a launch batch file with NET USE LPT1: and this has been working fine (with ESC codes) for years.
In my transition to Harbour I'm trying to embrace some new features, specifically around Win_Print******() functions but I've hit the buffers ...

Please, someone, help!

Daniele Campagna

unread,
Dec 28, 2024, 9:09:31 AM12/28/24
to harbou...@googlegroups.com

This can be useful (maybe):

function prn_info()
  // get printers
  aPlst:=win_printerList(.t.)
  actPrn:=win_printerGetDefault()
  nPrn:=ASCAN(aPlst,{|x|x[1]==actPrn})
  if nPrn>0
    cPort:=aPlst[nPrn,2]
  else
    // This should NOT happen
    alert("error: printer not found")
    quit
  endif
  alert("Default printer:"+win_printerGetDefault()+" On port:" +cPort)
  ALERT(cPort +" mapped to "+win_printerPortToName(cPort) )
return nil

To control the printing of a file you can use (PrintFileRaw=pfr):

function pfr(cPrinter,cFile)
  nBytes:=win_printfileraw(cPrinter,cFile)
  alert("Written "+str(nBytes)+" Bytes")
return nil

Tell us what happens with these functions...
Dan

Martin Fears

unread,
Dec 29, 2024, 8:40:07 AM12/29/24
to Harbour Users
Same FAIL :-(

I have attached the 3 Alert messages as screen-snips numbered in the order they appeared
Plus the A.TXT file being sent to Win_PrinterGetDefault()
The prn_info() confirms correct default printer and the port as (static) IP address
The A.TXT file contains no ESC codes to hopefully eliminate that possible question

As per - File name pops up on Print Queue (as expected) and I hear the printer initialise ....
Then nothing, until I hear the printer time-out, maybe 15 seconds later ...

WHAT IS (NOT) GOING ON ???

As an aside I don't think Win_PrintFileRaw() in hbwin returns the number of bytes printed (any more - maybe the older? PrintFileRaw() did?).
I believe returns from this (newer?) function are now:
1 = print success
0 = spooler success
-1 = Invalid parameters passed to function.
-2 = WinAPI OpenPrinter() call failed.
-3 = WinAPI StartDocPrinter() call failed.
-4 = WinAPI StartPagePrinter() call failed.
-5 = WinAPI malloc() of memory failed.
-6 = File <cFileName> not found.

Alert 2.JPG
Alert 1.JPG
A.TXT
Alert 3.JPG

Jayadev U

unread,
Dec 30, 2024, 10:32:54 AM12/30/24
to harbou...@googlegroups.com

HI Martn,

 

To my understanding, win_PrintFileRaw() is used to print to dot matrix printers.

 

For other printers which are GDI in nature (Including Laserjet printers) you may have to adjust the font.  Please try with the generic txt2gdi program which you can download the from the link below:

 

https://www.dropbox.com/scl/fi/6hyk4iwrv2t80oleefxdz/txt2gdih.prg?rlkey=zaxvhp1jpb0yu8z8b9mplflxh&dl=0

 

Call the function Txt2Gdi(cFile,cPrinter) with the text file and Printer name. (You may have to adjust the ESC code definitions to you requirements).

 

Just FYI, the following function has been working flawlessly over many years for printing on dot matrix printers

FUNCTION WinPrintRaw( cPrinter, cFileName, cDocName )

// This function prints the entire file in one call to PrintFileRaw()

   LOCAL nPrn := - 1, cMess := "WinPrintRaw(): "

    cDocName := iif(cDocName # NIL, cDocName,cFileName)

   if ! EMPTY( cFileName )

     #ifdef __XHARBOUR__

       if ( nPrn := PrintFileRaw( cPrinter, cFileName, cDocName ) ) < 0

     #else

       if ( nPrn := win_PrintFileRaw( cPrinter, cFileName, cDocName ) ) < 0

     #endif

 

         do CASE

         CASE nPrn = - 1

            Hb_Alert( cMess + "Incorrect parameters passed to function" )

         CASE nPrn = - 2

            Hb_Alert( cMess + "WINAPI OpenPrinter() call failed" )

         CASE nPrn = - 3

            Hb_Alert( cMess + "WINAPI StartDocPrinter() call failed" )

         CASE nPrn = - 4

            Hb_Alert( cMess + "WINAPI StartPagePrinter() call failed" )

         CASE nPrn = - 5

            Hb_Alert( cMess + "WINAPI malloc() of memory failed" )

         CASE nPrn = - 6

            Hb_Alert( cMess + "WINAPI CreateFile() call failed - File " + cFileName + " no" + ;

                    " found??" )

         ENDCASE

      ENDIF

   ENDIF

   RETURN( nPrn )

 

HTH,

 

Wbr,

 

Jayadev

Daniele Campagna

unread,
Dec 30, 2024, 11:26:10 AM12/30/24
to harbou...@googlegroups.com

I'm not sure that an IP address is a valid PORT name when printing in raw (DOS) mode.

Mapping the IP to LPT1 and printing to LPT1 should work - as in Clipper days (NET USE...).
At that point, the simple COPY a.txt LPT1 or ECHO a.txt > LPT1 should work from a command prompt, and so your program.

Dan

jgt

unread,
Dec 30, 2024, 9:55:30 PM12/30/24
to Harbour Users
There is also netcat:
Will allow you to send a file to any hostname on any port.

Martin Fears

unread,
Apr 8, 2025, 8:20:17 PMApr 8
to Harbour Users
Well, 3 months on the Harbour learning curve and my application migration to Harbour journey is complete.

Benefits: 
1. My old Clipper app now runs on 64bit Windows under Harbour
2. The printer ball-ache with Clipper LPT1: is resolved by using PSCRIPT, inc Print to PDF option
3. Any DOS folder / file name coding is now happy with long-names, no more "123456~1.txt"
4. Harbour allows more than 15 active indexes on a single DBF - very helpful in my application
5. no more memory usage concerns
6. I'm sure there are more, but these are the stand-outs I can recall of the last four months

Disadvantages:
1. Much use of NetLib functions - N_xxxxx() in my old app - www searching for a Harbour compatible found nothing so I had to find another way.
2. The one Netlib function I still need to replace is (DBF) file encryption / decryption - I don't want Excel users getting a look in ...
3. Size of the executable file has grown enormously (to over 3Mb), but not really an issue with 1TB drives as cheap-as-chips and not having to fit it on  to a 3½ floppy disk any more (remember those?)

Must give a shout-out to Simo (cod...@outlook.com) who helped me through the early deep, cold, dark waters of my journey in getting me up to speed with adopting Harbour - many thanks for all your help and patience Simo

Don Lowenstein

unread,
Apr 8, 2025, 8:36:12 PMApr 8
to Harbour Users
Congratulations, Martin.
Welcome to the family.


Sent: Tuesday, April 8, 2025 7:20 PM

To: Harbour Users <harbou...@googlegroups.com>
Subject: Re: [harbour-users] The journey begins?
 
GRAPHUS
Warning: The sender @harbour-users@googlegroups​.com might be a spam sender.

Alex Strickland

unread,
Apr 9, 2025, 3:18:34 AMApr 9
to harbou...@googlegroups.com

Hi Martin

Well done.

As far as encryption goes Harbour has your back. I hacked this out of my own code and it is untested in this form:


#include "dbinfo.ch"
#include "common.ch"
#define OF_SHARED        .T.
#define OF_EXCLUSIVE     .F.
#define OF_READONLY      .T.
#define OF_READWRITE     .F.
PROCEDURE MyDBUSEAREA(lNewArea, cDriver, cName, xcAlias, lShared, lReadonly, lEncrypt, lDecrypt)
    DEFAULT lEncrypt TO .T.
    DEFAULT lDecrypt TO .F.
    DBUSEAREA(lNewArea, cDriver, cName, xcAlias, lShared, lReadonly)
    IF NETERR()
        TraceOut("NETERR() is true on " + cName)
        RETURN
    ENDIF
    IF lEncrypt
        IF !DBINFO(DBI_ISENCRYPTED)
            IF lShared .OR. lReadOnly
                DBCLOSEAREA()
                DBUSEAREA(lNewArea, cDriver, cName, xcAlias, OF_EXCLUSIVE, OF_READWRITE)
            ENDIF
#pragma TEXTHIDDEN=1
            IF !DBINFO(DBI_ENCRYPT, "myfatpassword")
                TraceOut("Encrypting file " + cName + " failed")
                // Carry on?
            ENDIF
                // DBINFO leaves current record at LASTREC(), although are generally new and empty
            DBGOTOP()
            IF lShared .OR. lReadOnly
                DBCLOSEAREA()
                DBUSEAREA(lNewArea, cDriver, cName, xcAlias, lShared, lReadonly)
            ENDIF
        ENDIF
        DBINFO(DBI_PASSWORD, "myfatpassword")
#pragma TEXTHIDDEN=0
    ELSEIF lDecrypt
        IF lShared .OR. lReadOnly
            DBCLOSEAREA()
            DBUSEAREA(lNewArea, cDriver, cName, xcAlias, OF_EXCLUSIVE, OF_READWRITE)
        ENDIF
#pragma TEXTHIDDEN=1
        TraceOut("Decrypting file, returns " + IIF(DBINFO(DBI_DECRYPT, "myfatpassword"), "OK", "Failed"))
            // DBINFO leaves current record at LASTREC()
        DBGOTOP()
#pragma TEXTHIDDEN=0
        IF lShared .OR. lReadOnly
            DBCLOSEAREA()
            DBUSEAREA(lNewArea, cDriver, cName, xcAlias, lShared, lReadonly)
        ENDIF
    ENDIF
RETURN

HTH

--

Regards

Alex

Yakano

unread,
Apr 9, 2025, 12:48:25 PMApr 9
to Harbour Users
Hi, congratulations!

Use "hbmk2 FILE.hbp -compr" to compress EXE's size.

Regards.

Martin Fears

unread,
Apr 10, 2025, 11:34:16 AMApr 10
to Harbour Users
Hi Alex

Thanks for this .... 
With high expectations (I though I'd exhausted looking for a Harbour compatible NetLib library or Harbour encryption functionality) I've had a little play with it ....

I found that:
   1.  after successfully encrypting a dbf file  i.e. DBINFO( DBI_ISENCRYPTED ) == .T.
   2.  DBCLOSEAREA()
   3.  Exit Application
   4.  Fire-up DBU
   5.  Attempt to open the encrypted file >>> it opens the DBF, but all the data is zeros (N), garbled text (C), FALSE (L) or Empty (D)

This means that an inquisitive trespasser will still be able to see the DB structure (inc. Field Names, Type, Width, Dec) and, more worryingly, they can actually edit the data in DBU (while the file is in encrypted status).  After said DBU edit (and saved), when the file is then decrypted, any changes made by the rogue trespasser have overwritten the original data!!  Quite unsafe, I'd say, and kinda pointless encryption as all it's doing is disguising the data.

Pleased to confirm Excel not happy to open up an encypted DBF in this way, suggesting a file corruption, which is ideal.
With DBF files encrypted by NetLib(), DBU would bomb out when trying to open, as did Excel.

I want to fully protect the entire file by encryption, not just disguise the data within:
NetLib's N_ENCODE() & N_DECODE() worked a treat along with N_SETKEY() to set the "password"

My application is predominately data capture, manipulation and reporting, with many hours invested.  Not really Intellectual Property rights but I just don't want anyone trying to reverse-engineer my hard work for their own benefit.  I'm sure anyone determined will find a hack, I just want to keep straying / preying eyes locked out.

 - any (other) suggestions?

Angel Pais

unread,
Apr 10, 2025, 2:01:04 PMApr 10
to harbou...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages