From CA-Clipper to Windows in 5 Minutes

Do you still have old DOS-Programs based on CA-Clipper running on your system? This Howto shows you, how to speed up those programs by compiling them with hmg.

The Problem

Since the introduction of Windows XP, you probably get a 100% CPU-Usage as soon as you start your exe.

 

Even if your application is only waiting for user-input, it keeps your computer busy.

 

I can not fully explain the reason. But Clipper was not designed to be run in a multitasking environment and windows goes through great trouble to emulate a DOS-environment. So now as soon as your old program runs, even the fastest core duo system slows down to a creep. If you run it on a laptop, your batteries are empty quicker than you can say uncle.

Solution: Compile a Windows-friendly exe

But it does not have to be this way.

 

If you still have your source-code, you are lucky. You can compile it almost without any changes and turn it into an application that looks exactly the same, but runs much quicker and consumes only CPU-cycles when it is doing something.

 

There are many Clipper compilers out there. Some of them are even free. 

The compiler: Harbour

Harbour is a great compiler. It will take your Clipper source-code and turn it into C-Code that can be compiled into a binary. You can choose your compiler and there are many libraries that add functions to your program you never dreamt of. It will even run on Linux and Mac-OS.

HMG: A harbour-compiler with batteries included

If you are not interested in Linux and Mac-OS and all the fancy features, you just want an application that installs everything you need. A C-Compiler, binaries and batch files and even a lot of samples.

Such a program exists. It is called "Harbour MiniGUI", or just "hmg" for short. Visit the developers website:

http://harbourminigui.googlepages.com/

You can grab the latest version here:

http://www.hmgforum.com/site/

At the time of writing this post, 3.0.22 is the latest version. It is a 20 MB download. Users at hmgforum.com confirm, that it runs well with Windows Vista and Windows 7.

 

Update: Right now, the current stable version is 3.0.39 if you don't need postgresql-suppprt.

 

hmg 4.0 ist still in alpha-state. It's goal is to port the windows-api based gui to Qt and make it platform-independent. Be patient. It is not ready, yet.

Installing HMG

After you downloaded, the setup file, you can run a regular installer.

 

I recommend installing it into c:\hmg

 

 

Starting the IDE

The installation takes a few seconds. After it is finished, you have everthing you need. Compiler, Linker, Include-Files, etc.

 

You could compile your prg-files on the command-line, but I prefer the graphical IDE. It gives you a glipse into the many additional features you get with HMG.

 

Launch the hmg-ide either from the shortcut on your desktop or the startmenu.

The hmg-ide
The hmg-ide

Start a new Project.

You can place the project into your existing source-code directory on your harddrive. Make sure, you have a copy in case anything goes wrong.

 

The IDE creates a new "Main.Prg" and a new emty form "Main.Fmg". 

Removing Main.Prg and Main.Fmg

HMG is a great tool to build real Windows-Applications. It is abolutely amazingly simple to turn an existing Clipper-Program into a Windows-Program. But for now, we resist the urge to look at all the shiny features.

 

All we want to do is compile our console application.

 

So for now, we don't need the Main.Fmg and Main.Prg. Delete them by selecting them in the Project-Browser and clicking Project - Delete File from the Menu.

Adding your Source-Code to the IDE

Now you have an empty Project. Choose "Modules" in the Project Browser and click on "Project" - "Import File" in the Menu to import your all your prg-files.

 

The first one you choose will be your main-module. That means, it includes the procedure or function that starts the program. You can declare a module as main by clicking "Project" - "Set Module As Main" in the menu.

Console mode

By default, HMG wants to build a Windows-Application. But your old CA-Clipper-code is a console application.

 

So you have to tell the compiler to run in "Console Mode". You do that in the Project Browser in the Configuration-Tab.

Update: If you are using Version 3.0.39, there is noc "Console mode" any more in the "Configuration"-Tab. Don't panik. It still works. Simply add this line to your main .prg-file:

REQUEST HB_GT_WIN_DEFAULT

 

To be more precise, you now have a mixed-mode program. That means, you can already use windows-gui elements wherever you like.

Edit your Code

In some cases, you have to make little adjustments to your code.

 

Most importantly, harbour looks for a function or procedure "Main". If it does not find it, it will not do anything, because it does not know where to start.

 

Clipper also supported the first function to be named like the .prg-file. So open your prg-file with an editor of your choice and rename the main function.

 

The old prg-file will be saved in the codepage 850.

 

My favorite editor is jEdit. It calls the codepage IBM850. If some characters (umlauts, accents, box-drawing-characters, etc.) look funny, click "File" - "Reload with Encoding" - "IBM850".

 

Do not change the encoding. Keep it 850 for your console application!

Run

Compile your code by clicking "Project" - "Run" in the Menu.

 

HMG will build an .exe-file and launch it. So if all goes well, your program starts.

 

The new exe-File is rather large (1-2 MB) compared to an original clipper-exe. But who cares nowadays, right?

 

Here is a screenshot of a sample console application. As you can see, the wait-command does not keep the Processor busy.

Conclusion

This howto demonstrated, that you don't have to through away your old Clipper code and write it in a new language if you want an application that works well on Windows.

 

With hmg you can turn it into a modern harbour-console-program for windows within a few minutes.

What next?

You can now incrementally modernize your program. You might mant to start by replacing ALERT() with msgbox() to see how well it mixes.

HMG opens a lot of possibilities to really take old application to the 21st century.

 

I find it very impressive, that Roberto Lopez managed to extend the xBase Language, so that modern GUI-Controls can be defined in an easy to understand way.

 

Code looks like this:

 

#include "minigui.ch"

Function Main

    DEFINE WINDOW Win_1 ;
        AT 0,0 ;
        WIDTH 400 ;
        HEIGHT 200 ;
        TITLE 'Tutor 10 - Picture Button Test' ;
        MAIN

            @ 10,10 BUTTON PictureButton_1 ;
                PICTURE 'button.bmp' ;
                ACTION MsgInfo('Picture Button Clicked!!') ;
                WIDTH 27 ;
                HEIGHT 27 ;
                TOOLTIP 'Picture Button Tooltip'

    END WINDOW

    ACTIVATE WINDOW Win_1

Return

The IDE helps you build this code by designing your forms in a gui-designer.

 

If you want to know more about HMG, take a look at C:\hmg\SAMPLES and c:\hmg\DOC\hmgdoc.htm (also available online).

 

I found the people over at hmgforum.com very nice and helpful. They helped me when I got stuck and reading the forum gives a lot of insights.

Write a comment

Comments: 59
  • #1

    Hitman (Monday, 22 March 2010 08:28)

    Nice Info!

  • #2

    Micsa (Sunday, 02 May 2010 23:30)

    nice info thanks

  • #3

    edis (Sunday, 05 September 2010 16:42)

    Processor abuse problem was well known and fixed in late Clipper, problem only if you miss source code, perhaps.

    Even though DOS is heading into nowhere, Clipper had advantage to the very late of providing great base for flexible programming, as opposed to much more complicated programming for Windows platform. And relational data access level is still outstanding, making well questionable superiority of SQL. It may be personal, but with demise of Clipper I never had later in hands programming tool, that would match it in productivity, versatility. And there were quite some to work with.

  • #4

    Bicahi Esgici (Wednesday, 26 October 2011 23:41)

    Hi Ricci

    Could you allow me to publishing this very good article in my blog ?

    By noticing the source of course.

    Regards

  • #5

    raumi75 (Thursday, 27 October 2011 09:50)

    Yes, of course!

    I assume your blog is vivaclipper, right? Your blog was an important resource for me, when I was looking for a way to keep my clipper-program alive. I would appreciate it, if you linked back to this article.

  • #6

    Bicahi Esgici (Thursday, 27 October 2011 12:58)

    Thanks Raumi

    First, sorry for name confusion;

    second, thanks to your kind words :)

    Due to some obscure reasons ( in short, "Google pages" is prohibited in my country) my VivaClipper Google page is out of my access :(

    Now I'm struggling move my page to another page. I'm in the beginning and I have too many thing to work on. It's not announced yet.

    Pleas look at copy of your article:

    http://vivaclipper.wordpress.com/2011/10/26/from-ca-clipper-to-windows-in-5-minutes/

    If you like it please notify me your approwal.

    Regards

    --

    Esgici

  • #7

    Bicahi Esgici (Thursday, 27 October 2011 13:22)

    In addition; sorry, but I don't understand the "CA-Clipper" term or "Cl*pper" notation. IMO, CA is only owner of Clipper compiler, not Clipper language.

    What is your opinion ?

    Regards

    --

    Esgici

  • #8

    raumi75 (Thursday, 27 October 2011 18:09)

    It's great to hear that you are building a new site dedicated to clipper. Let's hope they don't start censoring wordpress.

  • #9

    raumi75 (Thursday, 27 October 2011 18:12)

    I am not really happy with the whole naming-issue. "Clipper" and "harbour" are too generic. If you google it, you get all kinds of results. For Search-Engine-Optimization-Reasons, I chose to call it CA-Clipper in this article as I am trying to address people who still use the old Compiler.

  • #10

    raumi75 (Thursday, 27 October 2011 18:34)

    So you can't access http://sites.google.com/site/vivaclipper2/ any more? I just made a mirror by running "wget -m" and zipped it. It is 3,4 MB. Do you want me to mail it to you?

  • #11

    Bicahi Esgici (Thursday, 27 October 2011 20:22)

    You are right in naming-issue. Perhaps I think such way because I hate CA ;)

    Thanks to your proposal about zipped file of my "site"; I have all necessary materials, including zipped full site.

    By the way, you don't noticed your approval on publishing your article; did you seen, and like?

    Regards

    --

    Esgici

  • #12

    raumi75 (Thursday, 27 October 2011 21:35)

    I posted my approval on your blog. Of course you can use the article.

  • #13

    Esgici (Saturday, 29 October 2011 12:09)

    Yes, I seen an answered

    Thanks again

    I'm waiting your further supports to xBase community.



  • #14

    esgici (Monday, 31 October 2011 20:28)

    Hi Raumi

    I changed URL of your article on my blog:

    http://vivaclipper.wordpress.com/category/clipper/articles/

    And instead of duplicate, I published it as a summary and added whole address in your blog.

    IMHO with this way no need to you notify me about modifications and to me re-copying or correcting my copy.

    What is your opinion ?


  • #15

    raumi75 (Tuesday, 01 November 2011 19:17)

    I think, this makes it easier to maintain, when I feel like I have to update something. Thanks for linking here.

  • #16

    Esgici (Tuesday, 01 November 2011 22:41)

    Thanks

    Have you see this post :

    http://hmgforum.com/viewtopic.php?f=19&t=2135#p18313

  • #17

    raumi75 (Wednesday, 02 November 2011)

    Wow, hmgforum links to my blog. I feel flattered. Thanks for telling me.

  • #18

    Esgici (Wednesday, 02 November 2011 18:06)

    You have furthermore :

    http://hmgforum.com/viewtopic.php?f=19&t=2135&start=10

    Congrats !

  • #19

    iliev (Tuesday, 10 January 2012 18:46)

    sorry, but don''e execute module dos/clipper with dows 7 / 64 bitswin

  • #20

    raumi75 (Thursday, 12 January 2012 18:33)

    I use Win 7 64 Bit and it runs well. What hmg-version did you use? Did you include REQUEST HB_GT_WIN_DEFAULT in your .prg file?

  • #21

    Ghost ship (Thursday, 12 April 2012 18:23)

    Great post! Thank you. While I was reading, was traveling about twenty years ago, when I had my first contact with programming, via Clipper and dBase. What good memories!

  • #22

    Eduardo Pintado (Wednesday, 25 April 2012 18:57)

    Great to know there's a chance to upgrade my DOS CA Clipper system.
    Q: Can be the new .exe binaries executed straight from Windows or should be triggered thru the IDE ? Many thanks

  • #23

    raumi75 (Thursday, 26 April 2012 11:41)

    HMG will create an .exe file that runs on Windows. You do not need the IDE to run the binary.

  • #24

    KAILASH (Thursday, 10 May 2012 13:55)

    I was trying to convert my clipper 5.2 app.
    Just after opening screen, I am getting an error
    "dbcmd/2001 workarea not in use DBCLEARFILTER. can u please help? Also, where to find error codes list? Thanks.

  • #25

    raumi75 (Thursday, 10 May 2012 17:09)

    Do you mean after compiling and running your new .exe? That would be a runtime error. Hard to tell what is causing it without looking at your code. Have you placed the .exe file into the same directory as your old, working .exe? Maybe this post will help you:

    http://www.hmgforum.com/viewtopic.php?f=5&t=2169

    The people at hmgforum are very friendly and helpful. There is also a Mailing List (http://groups.google.com/group/harbour-users/) and a Facebook group (https://www.facebook.com/groups/harbour.project/) where you can ask questions.

  • #26

    Boban (Monday, 18 February 2013 22:29)

    Hi, I am using HMG to convert my old ca-clipper apps to windows gui apps. I want to know how to define window for each procedure; in the procedure itself, or to call the procedure when windows initializes?

  • #27

    raumi75 (Tuesday, 19 February 2013 10:13)

    Hi, I am not sure I understand your question. A good start is looking at the many samples in your HMG-folder. I good place to ask such questions is hmgforum.com. The people are very knowledgable, helpful and friendly.

  • #28

    Nick (Saturday, 20 April 2013 09:12)

    Hello, I've converted my old Clipper 5.1 app into Harbour using HMG. I can run now my app, my problem is that when I type in data, the screen scrolls up line by line with every data I input, so I don't see anymore the already typed in data. I use classic contruction lines.
    @ row, col say 'Type in data: ' get some_data
    read
    Any ideas? Thank you.

  • #29

    Tim ODell (Thursday, 13 June 2013 06:42)

    I've installed version 3.1.3 on both Windows 7 and Windows XP, and cannot find an icon for the MiniGui program. Which program to start it, and which directory is it in?
    --Thanks
    PS: I agree completely about newer programs being difficult. I'm still maintaining programs from th 80's that clients love!

  • #30

    raumi75 (Wednesday, 19 June 2013 12:51)

    Depending on the path you declared at installation time, it should be c:\hmg.3.1.3\ide\ide.exe

  • #31

    walt (Thursday, 30 January 2014 23:02)

    is there anything that can be done if I don't have the source code

  • #32

    raumi75 (Tuesday, 04 February 2014 10:53)

    You will need a decompiler. I have no experience with them. Try to google that. You might want to try and ask people in the hmg-forum.com or the official harbour mailing list.

  • #33

    aks (Friday, 21 February 2014 12:21)

    i have build my exe using hmg (minigui) . which is error free. my .exe is not getting executed . i am using Vista OS

  • #34

    Rick451 (Friday, 14 March 2014 06:38)

    I wrote a program for a company in Clipper 5.1 (DOS) in 1990, installed and tested it on their Novell network and that was it. Much to my surprise I got my first call for support in 2009. I couldn't believe that they were still using it on a daily basis after 19 years. They had a corrupted database with errant EOF markers and I had written a program in C to correct that and recover nearly all of the lost data in 1993 so I simply e-mailed them the program and poof no more problems. I have found Clipper to produce extremely well behaved programs under virtually any operating system from DOS through Windows XP, including Lantastic and Novell networks running over DOS as well as Windows networks. I did find that my version of Clipper doesn't trap as many errors as I would like so I usually run the main Clipper .EXE application from a shell written in C+ and return error codes to the shell which can deal with the error and respond accordingly. It works.

  • #35

    BKScooter (Thursday, 17 July 2014 01:38)

    Wow - stumbled across this thread and, like ghost_ship, was thrown back in time. I started with Clipper Winter '84 as a newbie dBaseII programmer and managed to build a consulting company and make a good living writing Clipper apps for almost 20 years. (Including a chunk of Y2K mods!) I was a beta tester for several versions and ran a fairly successful Clipper User Group for a few years. I agree with the other comments regarding the longevity and durability of Clipper apps. The original team at Nantucket were visionaries but the open architecture and explosion of innovative third-party libraries is what really made it a productive platform. Blinker, WarpLink, Grumpfish etc.....Thanks for the memories!

  • #36

    fabius (Monday, 18 August 2014 10:53)

    I tried to compile my old prg files ,but it show Cannot open RPCW.prg, assumed external
    Cannot open RPCL.prg, assumed external
    Cannot open RPCW2.prg, assumed external
    Cannot open RPCL2.prg, assumed external
    Cannot open RPCL3.prg, assumed external
    Cannot open RPCL4.prg, assumed external
    what is the problem ???? Actually these are not prg file, but procedure or function inside a few prg files.
    How to link it together ?

  • #37

    Ron Booth (Sunday, 24 August 2014 17:50)

    Do the programs compiled with HMG run in Windows 7 or 8 without purchasing special programs for Windows?

  • #38

    raumi75 (Sunday, 24 August 2014 21:40)

    Yes, they run on Windows 7 for sure. Have not tried Windows 8, but it should work. Take a look at hmgforum.com for people more knowledgeable than myself.

  • #39

    Bart Tecter (Thursday, 28 August 2014 17:45)

    This may just be the light at the end of a 30 some year tunnel... I wrote a very large database application for a company in the late '70's. It has been modified and updated somewhat over the years and is still in daily use today. With Windows 7 I now have a problem. I have attempted to recompile the program with the instructions above. However, when I try to run the project I get numerous "Multiple definition" errors from the mingw linker. These seem to happen wherever a .prg file is called from within another .prg program. Any Idea what I need to look for to fix the problem?

  • #40

    Agil Abdullah Albatati (Thursday, 04 September 2014 13:27)

    Hi Raumi,

    This's very helpful to me to start with compiling *.prg

    Many thanks from Jakarta, Indonesia

  • #41

    Sadqat Ali Awan (Friday, 12 September 2014 03:50)

    FIRST I AM NOT PORGRAMMER I AM A RETIRED ACCOUNTANT AND NOW WORK AS PART TIME WORK WITH OWN CLIPPER ACCOUNT PROGRAMME. THANKS FOR ALL I COMPILE THE .PRG IN TO HMG 3.3.1 ALL WORK OK ONLY TWO
    PROBLEUM.
    1- VOUCHER FORM WRITE IN LOWER SIDE INSTUD OF UPPER SIDE.
    2- MY PRINTER CODING IN GNRLLIB ALL LIB CODDING WORK WERY WEEL INSTUD OF PRINTER CODDING LPT-1 ETC.

    ANY BODY HELP ME
    awan_g @yahoo.com

  • #42

    Jota (Thursday, 26 March 2015 18:59)

    The tips are wonderfull, but i dont know how to print with
    SET PRINTER TO PRN
    after compiling com HMG.
    I need some help.

  • #43

    Ramon Preston (Friday, 24 July 2015 03:44)

    Anybody out there can really convert a Clipper prog to a Windows prog in 5 minutes? If so I have a program that needs converting. I am sure the customer would be willing to pay a (reasonable) fee to have it done.
    My 20+ year old program won't run on the newer Windows nor Dosbox nor Virtual computers. Needs a true Windows version. Yeah, I'd even let you use it without question.

    Send emails to: rpreston7@twcny.rr.com

  • #44

    Software Toko (Thursday, 30 July 2015 09:05)

    I have been trying to recompile the program with the instructions above. Thank you for this article was very useful for me

  • #45

    pva (Thursday, 24 September 2015 09:23)

    Hi. I have clipper 87 PRG files. I want to run on windows 8. Please help

  • #46

    Bimal Dutta (Saturday, 26 September 2015 07:25)

    Please help me, i have developed clipper 87, now i have not progress in windows 7 & windows 8 by my programme, i am very poor, further i could not developed my programme. please help me with your suggestion & give me your help books with sample programme & your software.

  • #47

    klaumel (Sunday, 08 November 2015 11:36)

    Ich versuche gerade PostgresSQL mit HMG zu erreichen. Erhalte aber bei der Demo (C:\hmg.3.4.2\SAMPLES\HFCL\SQL\POSTGRESQL_1) die Fehler:
    undefined reference to `HB_FUN_DBPGCONNECTION' und HB_FUN_PGRDD.
    Leider habe ich keine Lösung gefunden.

  • #48

    raumi75 (Wednesday, 11 November 2015 09:23)

    Ja, das ist echt schade. PostgreSQL-Support ist nicht besonders stabil, weil es wohl nicht viele benutzen. Ich verwende Version 3.0.35. Das läuft. Es kann sein, dass andere Versionen funktionieren. Ich habe vor Jahren aufgegeben, die neuen Versionen auszuprobieren.

    Das hmg-Forum lässt aber darauf schließen, dass es auch andere Versionen gibt in denen postgresql unterstützt wird:

    http://www.hmgforum.com/search.php?keywords=postgresql

  • #49

    Bimal Dutta (Friday, 12 February 2016 11:42)

    1. How can i open multi files with index files (70 files) at a time in a one programme, platform of 64 bit machine? (2) How can i operate One Entry field to next entry field by Enter Key. please send with examples, otherwise HMG programme not completed.

    - please solved the above problems and send me with examples , I awaiting for you.

  • #50

    Sadaqat Ali (Tuesday, 12 April 2016 05:18)

    I Compile clipper 5.2 prg with the help of my best fried Mr. esgici with hmg 3.3.1.exe and very well work as clipper and open the make hmg.exe in windows 8,10 32,64bit best.
    only one problem usb printer work best in .clipper.exe through dosprn program capture lpt1 attach printer or network printers.
    But no work usb printer with compile hmg.exe. if passible work as clipper.exe printer and I enjoy my clipper old soft wear with the
    New windows.
    Please any body help.

  • #51

    Save Samurai Warriors 4-II 100% Tamat (Saturday, 09 July 2016 05:48)

    I use Win 7 64 Bit and it runs well. What hmg-version did you use? Did you include REQUEST HB_GT_WIN_DEFAULT in your .prg file?

  • #52

    leyraone (Saturday, 05 November 2016 11:03)

    when I clicked Run under the Project Menu...there is an error under the Build Log:
    "Fatal: Unable to open file 'MINIGUI.LIB'"

    Thanks

  • #53

    raumi75 (Monday, 07 November 2016 10:04)

    You should post your question on hmgforum.com

    I'm sure someone will be able to help you install hmg.

  • #54

    Rob (Thursday, 30 March 2017 15:43)

    Am having same issue as others. Have an extensive group of clipper apps and am trying to use IDE to take advantage of better memory handling. However, I keep getting a very large amount of multiple definitions errors and it won't produce the executable.

  • #55

    Jos Schaars (Thursday, 13 April 2017 21:51)

    Another option to run Clipper compiled programs in Windows 32 or 64-bit is vDos (www.vdos.info).
    If Harbour will do the job (the best solution), vDos could at least lessen the pressure to do any needed conversion.

  • #56

    Rob Scarpa (Wednesday, 06 December 2017 01:39)

    I needed to update our 32 Bit computer systems and was frustrated as everything out there is 64 Bit and would not run my integrated business 16 but invoicing, inventory, and receivables software.

    Ran across HMG and gave it a try. A few added lines as stated above in the lead-in prg files and they compiled 32 Bit which I can now run in the 32 bit as well as 64 bit systems on the network while making maximum use of windows memory management.

    Thank you for bringing my into the current century.

  • #57

    maQSur (Sunday, 13 May 2018 23:02)

    hi raumi75,

    Thank you very much for sharing the method with us.
    I tried your method and it is working.

    I have a problem and I hope you can help.

    does not support the Turkish language..

    " Ş ş İ ı Ü ü Ö ö Ç ç " characters do not appear :(
    I did some research and nothing I tried did not work.

    I would be very happy if you can help in this regard.

    Thank you in advance...

  • #58

    Johannes Schumann (Tuesday, 02 October 2018 04:12)

    I need someone who can help me to convert *.prg files from CA-Clipper to Windows. I am still using Vista 32 bit. Now I am using Windows 10. I will pay for it.

  • #59

    H. Christiansen (Friday, 19 October 2018 02:05)

    Hallo Herr Schumann,
    Wahrscheinlich kann ich Ihnen helfen.
    Ich habe einige alte Programme (Clipper 87) in die neue Welt überführt.
    Wie kann ich Sie erreichen?
    Mit freundlichen Grüßen
    H. Christiansen