Building in xHarbour w/o make file?

156 views
Skip to first unread message

cgallery

unread,
Sep 7, 2025, 3:51:42 PM (11 days ago) Sep 7
to Harbour Users
Hello.  I've been using the Harbour compiler for some time to maintain a little program I wrote starting back in 1990 (using Clipper).

A feature I recently added using the hb_IdleAdd to add a function that, if there has been no activity for ten seconds, closes all the file handles (recording in an array all the details of the open files).  It then waits for a keypress, and when there is one, it reopens all the files.

I do this so if I sleep my notebook computer w/o closing my app, I can then wake my laptop and continue using my app w/o any errors due to network files no longer being accessible (due to the sleep).

The problem was, using the Harbour compiler, once I had closed the files and was waiting for a keypress, the CPU usage went up a lot (10-12%, enough to cause the CPU fan to speed-up).  Nothing I did to rewrite the part of the code for waiting for the keypress could resolve this, everything used as much CPU as inkey.

So I downloaded xHarbour and was able to get the CPU usage down to 0% by calling SecondsSleep().  I double-checked by compiling with the latest Harbour (not xHarbour) and SecondsSleep() compiles but still high CPU utilization.

So basically xHarbour for the win.

The only thing that I don't like about xXarbour is that I seem to need a make file for everything I compile.  Even helloworld.prg, I'd need a make file.  With Harbour, I had a batch file  (bld.bat) and could just type "bld helloworld" and it compiled any simple little code I was testing.

Is there any chance of doing this with xHarbour?

Thank you everyone it is wonderful to see all this help and support continuing.

cgallery

unread,
Sep 7, 2025, 4:14:33 PM (11 days ago) Sep 7
to Harbour Users
BTW, my bld.bat from harbour contains:

hbmk2 %1 -compr -lhbxpp.hbc -lhbtip -lhbct -lxhb -lhbmisc -lhbwin /w

...I'm looking for a means to do something similar in xHarbour, but I don't know if it is possible.

Francesco Perillo

unread,
Sep 7, 2025, 4:18:24 PM (11 days ago) Sep 7
to harbou...@googlegroups.com
How do you wait for a key press?
A loop around inkey().
If yes try to change to inkey(1) or bigger number.

--
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/4cf4ba01-cbec-4216-9ddb-2c5181bae4f8n%40googlegroups.com.
Message has been deleted
Message has been deleted

cgallery

unread,
Sep 8, 2025, 3:10:34 AM (11 days ago) Sep 8
to Harbour Users
Yes, I do a loop around inkey.  At least as far as any functions running while idle, the parameter passed to IdleAdd seems irrelavant as the CPU usage is high no matter what.

What I do is inkey() and then SleepSeconds(1), this works in xHarbour but not in Harbour, to reduce CPU usage.  There can be an average 0.5 seconds delay to "wake" my app up and to have the files opened up, but that is okay.

Interestingly (to me at least), if I specify inkey(1) and SleepSeconds(1), my CPU usage actually increases to about 2% in xHarbour.

I suspect inkey works differently in functions running when idle.

cgallery

unread,
Sep 8, 2025, 3:12:20 AM (11 days ago) Sep 8
to Harbour Users
Yes, I've tried a loop around inkey(1) but in both Harbour and xHarbour, that doesn't alter CPU usage in an idle function.

At least in xHarbour, SleepSeconds(1) does actually stop CPU usage.  SleepSeconds(1) compiles in Harbour but it doesn't alter CPU usage.



On Sunday, September 7, 2025 at 3:18:24 PM UTC-5 Francesco Perillo wrote:

Francesco Perillo

unread,
Sep 8, 2025, 3:50:33 AM (11 days ago) Sep 8
to harbou...@googlegroups.com

inkey(1) stops program execution for 1 second or until a key is pressed
inkey(0) stops program execution until a key is pressed

I'd use inkey(0) and let the Harbour runtime library take care of everything. Of course I'd remove all the SleepSeconds calls

Francesco

cgallery

unread,
Sep 8, 2025, 8:33:11 AM (11 days ago) Sep 8
to Harbour Users
Inkey() works differently when called by functions running via HB_IdleAdd.  Nothing you pass to it will cause CPU usage to drop.

This is true in both Harbour and xHarbour.

Your only chance is to find something that actually rests the CPU.  In xHarbour that seems to be SleepSeconds(), but SleepSeconds() doesn't help in Harbour (it compiles, but the CPU usage is still high).
Message has been deleted

pete....@gmail.com

unread,
Sep 8, 2025, 9:53:02 AM (11 days ago) Sep 8
to Harbour Users
hb_releaseCPU() perhaps?

cgallery

unread,
Sep 8, 2025, 10:13:59 AM (11 days ago) Sep 8
to Harbour Users
Oh my gosh, you're RIGHT!  If I use inkey() in a loop with hb_releaseCPU(), my CPU utilization drops to zero, according to Task Manager, and my fan in my notebook doesn't ramp-up.

Thank you so much for your help!!!

Gerald Drouillard

unread,
Sep 8, 2025, 10:27:08 AM (11 days ago) Sep 8
to harbou...@googlegroups.com
For harbour have you tried hb_idlesleep()

--
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.

cgallery

unread,
Sep 8, 2025, 10:30:20 AM (11 days ago) Sep 8
to Harbour Users
Yes, it didn't help.   hb_releaseCPU() (suggested above) works perfectly in Harbour.  I have not tested it in xHarbour as I prefer Harbour because I like building via the simple bld.bat file.

I don't know if that is a mistake, if I'm giving up something by using Harbour instead of xHarbour.
Reply all
Reply to author
Forward
0 new messages