Danny A. del Pilar

Contributed works of Danny A. del Pilar

Browse Test Demo

Easter Sunday Calculation

Generate Gregorian Calendar

HMG source code converter

How to build menu like old ACHOICE function?

KPI (Key Performance Indicator) Dashboard

Return value from modal window (Record Picker) 

Similar SCATTER / GATHER en HMG

Building console application

How I can build a console application via HMG ?

We have a paradox here: though HMG is a GUI library, we are requesting a non-GUI service; since console means non-GUI.

But don’t wory, this is possible; even very easy, such as any HMG application, and with more than one method.

Method 1: Batch processing:

( Assuming HMG root folder is C:\hmg and name of your console application project file name is ConsOnly.HbP and your main prg file name is ConsOnly.Prg )

call c:\hmg\build.bat /c ConsOnly

( No matter ConsOnly is a project or program file. )

If your project has more than one .prg file, you may use build.bat such ways:

1- call c:\hmg\build.bat /c progr1 progr2 prog3 ...

.OR.

2- First build a .hbp file contains such as:

progr1
progr2
prog3

and say name is “ConsOnly.Hbp” then invoke build.bat:

call c:\hmg\build.bat /c ConsOnly

The /c ( or /C ) switch inform build.bat about console.

You can omit this switch, by adding this line to top of your .prg file:

REQUEST HB_GT_WIN_DEFAULT

Method 2: Via HMG-IDE:

First you need add abowe

REQUEST HB_GT_WIN_DEFAULT

line to top of your .prg file.

And then, building a project file ( .hbp ). For example if your .prg file name is ConsOnly.prg, you may use a ConsOnly.HbP  file contains one line:

ConsOnly.prg

If your project has more than one .prg file, your project file contains a list of that .prg files. For example:

progr1
progr2
prog3

You may build this project file simply writing with a text editor or by selecting “New Project” within HMG-IDE.

And only thing is pressing “Run” button.

Yo don’t need any other thing.

Caution:

Don’t include

#include <hmg.ch>

line into console-only .prg’s.

Technically no problem, you can add. Moreover with this  way, though project is console mode,   you can see error messages in GUI mode. But has a risk: may be some HMG functions have same names with Harbour and if you include “hmg.ch”, HMG functions will override others; an example may be  BROWSE(). If this is your intend,  no problem. But this situation sometime may be a nightmare.

Building a HMG application

How I can build a HMG applications ?

Build.Bat / HMG-IDE

– BUILD.BAT

The easiest way is to use the ‘build.Bat’ file located at \hmg folder.

Usage:

Build [/i|/r|/d|/cs|/ci/cr] <PrgFile> | <filelist.hbp> [config.hbc]

[/i] : incremental build

[/r] : incremental build (rebuild all)
[/cs] : Console/mixed mode (std build)

[/ci] : Console/mixed mode (incremental build)

[/cr] : Console/mixed mode (incremental rebuild all)
[/d] : Debug mode (gui and console)

<filelist.hbp> : A text file with .hbp extension containing a source list.

<configfile.hbc>: A text file with configuration parameters as additional libs, include paths and lib paths.

<configfile.hbc> Syntax:

incpaths = incpath1 incpath2 … incpathn

libpaths = libpath1 libpath2 … libpathn

libs = lib1 lib2 … libn

mt = yes (multi-threading support)
– library names must not include ‘lib’ prefix nor ‘.a’ extension.

– ‘build.bat’ will create an ‘error.log’ file in the app folder when build process ends with an error condition.

– <.hbc> files in the current folder are automatically processed.

Sample: \HMG\SAMPLES\MULTI.PRG

– HMG IDE

This programming environment allows visual form editing and application build.

Environment settings (HMG Folder, Program Editor, etc.) are stored in ‘.ini’ files, located at IDE folder.You can interactively change default settings (Main Menu->Tools->Preferences).

In IDE, all build customizations must be handled by the user from ‘Configuration’ (project browser) tab. It is direct edit of the project .hbc file. Look at hbmk2 help for details. By default two gt drivers are ALWAYS linked: GTGUI (as default) and GTWIN (Windows console). To create console/mixed mode apps. you only must add this line to your main .prg: HB_GT_WIN_DEFAULT

When upgrading HMG, please, clean previous build data from your projects using incremental building. From command line, you must add the -clean parameter. From IDE, use the ‘Reset project incremental data’ option from the project menu.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note:  This post borrowed from official HMG Docs.

Build a Harbour application

How I can build a Harbour applications ?

Method 1 : By batch processing:

First you have two path definition: harbour\bin and mingw\bin

If  HMG installed in your PC, harbour and mingw directories are already exists. If your HMG root <dir> is c:\hmg, harbour\bin is :

C:\hmg\HARBOUR\bin

and your mingw\bin is

C:\hmg\MINGW\bin

If  HMG not installed or you want use other than HMG folders, you will change paths definitions according to your choice.

Than for this path definitions you will enter (preferably by a  a .bat file ) a command like this:

SET PATH=c:\hmg\HARBOUR\bin;c:\hmg\MINGW\bin;%PATH%

After run this batch file, it’s sufficient a single command for build your application ( in your working directory including <MyProg> of course ):

hbmk2 <MyProg>

hbmk is probably ultimate utility in make area; extremely versatile and extremely successful.

By command window (after changing current directory to harbour\bin or setting path as mentioned below) enter

hbmk2

(without any more world) for short help and

hbmk2 -help

for long one.

More detailed help may find in Harbour Project users’ mailing list.

Method 2 : By hbIDE

( With words of author, Pritbal Bedi) hbIDE, as the name implies, Harbour’s Integrated Development Environment, is an open-source, multi-platform, project. hbIDE is aimed at simplifying the process of project life-cycle comprising, setting-up the project components, editing the sources, building them to final binaries.

You may find more info on hbIDE  herehere and  project home page.

Building Harbour / HMG

How I can build Harbour and / or HMG?

Harbour and HMG both are open source project and it’s possible to (re)build them in your own machine.

But before we need find an answer to the question “why?”.  Both projects has their own binary ( executables, libs, etc ), even setup prg. If you want play on source code, surely you will find building method(s) by digging package.

Making some change in the source code may be educative, useful for understand more deeply the system; but sometime may be also  annoying.

First changing system source files will be risky in general; while changing some place, will be problematic other places, and at least you have make same change repeatedly for every next release of compiler / library.

And second, you have re-build compiler /  library for every change you made.

There is a mymake.bat and win-mak.exe in Harbour package and HMG has buildlib.bat .

And, an excellent tutorial How to build HARBOUR … by an excellent Harbour fan: Giovanni Di Maria.

Anyway, since primary goal is address to beginners, details of this issue is out of scope of this blog.