Clipper Tutorial: a Guide to Open Source Clipper(s)/Getting Started

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Getting Started[edit]

A simple graph showing the different ways one can use (x)Harbour, and how they correspond to BASIC interpreters and Java.

As seen above, in practice, (x)Harbour permits a great versatility, as it (they) can be used in four different ways:

  1. by running hbrun or xbscript and executing instructions interactively (much like a BASIC direct mode or immediate mode, although it is more similar to the dBase dot prompt). The main limit of this approach is that it cannot run expressions longer than a single line (but it is possible to enter more instructions on a line separating them with semicolons). However, much of my tutorial is thought to be entered, tested and understood one line at a time.
  2. by calling hbrun or xbscript specifying a .prg file as a line argument to execute it (which is again like specifying a file to run when invoking a BASIC interpreter)
  3. by compiling the file to a bytecode using the /gh option of the Harbour compiler and then running the resulting .hrb bytecode file with hbrun (this is similar to Java's workflow when you call the compiler javac and then the Java interpreter on the bytecode file)
  4. by using the Harbour compiler, C compiler and linker to get an executable file (utilities are given to get all the steps done in a single command)
  5. by using the compiler through an IDE

There are also commercial RADs, like Xailer (https://www.xailer.com/) or xHarbour Builder (https://www.xharbour.com/).

Antonino Perricone wrote an extension for Visual Studio Code, which is well documented at https://github.com/APerricone/harbourCodeExtension/wiki, https://medium.com/harbour-magazine/visual-studio-code-for-harbour-e148f9c1861a, https://harbour.wiki/index.asp?page=PublicArticles&mode=show&id=190401174818&sig=6893630672. The main problem with the precompiled version of Visual Studio Code is that it's not under the MIT license.

https://github.com/Petewg/harbour-core/wiki/Make-tools

xMate IDE: https://github.com/Petewg/MgM/tree/master/comp/ide

Packages providing syntax highlighting for various editors are available: for Sublime Text (https://www.sublimetext.com/) is available at https://github.com/asistex/Sublime-Text-harbour-Package, for SynWrite (http://www.uvviewsoft.com/synwrite/) at https://github.com/rafathefull/synwrite, for Atom Editor (https://atom.io/) at https://github.com/AtomLinter/linter-harbour, UltraEdit at http://forums.ultraedit.com/syntax-highlighting-wordfile-for-harbour-fivewin-t17880.html. I myself like Scintilla (https://www.scintilla.org/), a lightweight open source editor that supports the xBase syntax highlighting under the name Flagship - which is an implementation different from the open source ones we are considering but that does not make much difference and it's anyway highly configurable.

Using Harbour From a Windows Command Prompt[edit]

Simply open a command prompt and move to the directory where you store your sources. Issue a PATH command pointing to the bin directory of your Harbour system (this is to avoid problems if you've got different compilers in your system). I also add the path of a text editor to use from the prompt, like this:

D:\harbourcode>PATH c:\hb32\bin;D:\wscite

Getting Started With hbIDE[edit]

https://hbide.vouch.info/

  1. To create a new project, select File > New > New Project Wizard (Prototype Only). We will name this project hbidetest, enter the path C:/hb32/projects/hbidetest.hbp and click Save and Close.
  2. Select File > Open Project in the menu bar.
  3. Right click the project hbidetest in the projects dock on the right and "Set as Current" project.
  4. Select File > New > Source and create a file hbidetest.prg with the following content:
     function MAIN
     * This is an example
     clear
     ?"Hello, the weather is fine today"
     ?"(this is a test of HbIDE)"
     wait && will show "Press any key to continue..." and prevent the console window to close immediately
     return
    
  5. Double click hbidetest in the projects dock so that the and click the Select Sources button near the Project Output text box, then select Save and close. It is a button not very well indicated - I think a button clearly stating "Add source file" would have been better. "Select Sources" Button Position in hbIDE
  6. Now after selecting Build > Build and Launch our program will show up.