harbour_complete_programming_book.pdf

445 views
Skip to first unread message

antonio....@gmail.com

unread,
Jun 6, 2025, 6:31:11 AMJun 6
to Harbour Users
Done with https://agent.minimax.io/

Still not complete but improving

best regards

Antonio
harbour_complete_programming_book.pdf

Ash

unread,
Jun 6, 2025, 1:52:25 PMJun 6
to Harbour Users
Hello Antonio,

Thank you for sharing your book.

I remember when you initiated the Harbour Project many years ago – it's remarkable how Harbour has become such a versatile, platform-agnostic tool. Who would have imagined its success!

I'm confident your book will, in time, effectively address the critics of Harbour documentation and attract many new users.

Regards,
Ashfaq Sial

priadi andika

unread,
Jun 8, 2025, 10:05:23 AMJun 8
to harbou...@googlegroups.com
Hi Group 

 

I just migrated from clipper to harbor and it runs smoothly

My problem is that it only displays full screen exe file when running

Can anyone help?

SetMode( 25,  80 )    ( Not Efect )

I use window 11 


Thanks for attention , help and support 

BR

SPD





--
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/7ffcc607-a6da-4ff3-a6e0-3f7f59ea2f2an%40googlegroups.com.

priadi andika

unread,
Jun 9, 2025, 3:55:44 AMJun 9
to harbou...@googlegroups.com
Hi Antoni 

We are waiting for the continuation of this book.
This book is very good for reference.
We are waiting for the continuation of the discussion of the following 

Part III: Functions and Procedures
Defining Functions
Parameters and Return Values
Scope and Variables
Built-in Functions

Part IV: Object-Oriented Programming
Classes and Objects
Inheritance and Polymorphism
Methods and Properties
Advanced OOP Concepts

Part V: Database Programming
Introduction to RDD
Working with DBF Files
Indexes and Relations
SQL Integration

Part VI: File and I/O Operations
File Handling
Text Processing
Network Programming
Graphics and User Interface

Thanks you for contribution and dedication to the harbour community

Best Regard
SPD


Pada Jum, 6 Jun 2025 pukul 17.31 antonio....@gmail.com <antonio....@gmail.com> menulis:
--

gfil...@gmail.com

unread,
Jun 9, 2025, 5:13:10 AMJun 9
to Harbour Users
Hi,

Please look at this proposed chapter.

-----------------------------------------------------------
Chapter 10: Database Programming

A lighthouse keeps watch, but it is the detailed logs that record every event. In Harbour, database programming is your system’s logbook—an essential foundation for building robust, data-driven applications.

Harbour shines in database applications. Built as a successor to Clipper, it natively supports DBF files, indexes, and multiple RDDs (Replaceable Database Drivers), giving you the power to create, read, update, and delete data with ease.

---

Introduction to RDDs

RDD stands for Replaceable Database Driver, the architecture Harbour uses to abstract database access.

Common RDDs:

 DBFNTX: Traditional Clipper-compatible driver (DBF + NTX)
 DBFCDX: FoxPro-style indexing (DBF + CDX)
 DBFNSX: Third-party NSX format
 SQLRDD: SQL database support (experimental)

Selecting RDD:

RDDSETDEFAULT("DBFCDX")

This sets the default database engine. Defaults to DBFNTX if unspecified.

---

Working with DBF Files

1. Creating a DBF File

PROCEDURE CreateDB()
   DBCREATE("customers.dbf", ;
      { {"ID", "N", 5, 0}, ;
        {"Name", "C", 30, 0}, ;
        {"Email", "C", 50, 0}, ;
        {"Active", "L", 1, 0} })

   ? "customers.dbf created."
   RETURN

---

2. Opening and Browsing a DBF

USE customers NEW
BROWSE()
USE

BROWSE opens a basic interactive viewer. Perfect for testing.

---

3. Appending Records

USE customers NEW
APPEND BLANK
REPLACE ID WITH 1, ;
        Name WITH "Alice", ;
        Email WITH "al...@example.com", ;
        Active WITH .T.
USE

---

4. Searching and Locating

USE customers NEW
INDEX ON Name TO custname
IF SEEK("Alice")
   ? "Found:", Name
ELSE
   ? "Not found."
ENDIF
USE

For this to work, you must have an index on the searched field.

---

Indexes and Relations

Indexes speed up searching and sorting.

1. Creating an Index

USE customers NEW
INDEX ON Name TO custname
SET INDEX TO custname

2. Using Multiple Indexes (Tags in CDX)

INDEX ON Email TAG email TO custidx
INDEX ON ID TAG id TO custidx
SET ORDER TO TAG email

---

3. Relational Navigation

USE customers NEW
USE orders NEW ALIAS ord

SET RELATION TO ID INTO ord

? "Customer Orders:"
DO WHILE !EOF()
   ? "Customer:", Name
   ord->(DBSKIP())
   SKIP
ENDDO

USE

---

SQL Integration (Optional / Advanced)

Harbour can connect to external SQL databases via ODBC, ADO, or wrappers like hbmysql or hbodbc.

Example using hbodbc:

PROCEDURE ConnectToSQL()
   LOCAL oConn := TODBC():New( "DSN=mydb;UID=user;PWD=pass" )
   IF !Empty(oConn)
      oConn:Open()
      ? "Connection successful."
      oConn:SetSQL( hConn, "SELECT  FROM employees" )
      oConn:Destroy()
   ELSE
      ? "Connection failed."
   ENDIF
   RETURN

> For production-grade SQL access, consider using Harbour with external C libraries or wrappers.

---

Locks and Multi-user Access

Harbour supports record-level locking for concurrent use:

USE customers NEW SHARED

IF RLOCK()
   REPLACE Name WITH "Updated Name"
   UNLOCK
ELSE
   ? "Unable to lock record."
ENDIF

Use FLOCK() to lock the entire file (not recommended for multi-user).

---

Database Utilities and Functions

| Function                   | Description                |
| -------------------------- | -------------------------- |
| DBCREATE()                 | Create DBF file            |
| USE                        | Open DBF                   |
| APPEND                     | Add new record             |
| REPLACE                    | Modify fields              |
| SKIP, GOTO                 | Navigate records           |
| SEEK, LOCATE, FIND         | Search records             |
| DELETE / RECALL            | Mark/unmark for deletion   |
| PACK                       | Permanently remove deleted |
| INDEX, SET INDEX           | Index creation             |
| RLOCK, FLOCK, UNLOCK       | Locking                    |
| DBEVAL, FOR EACH           | Record iteration           |


---

Practical Example: Customer Management

PROCEDURE Main()
   LOCAL nID := 1
   USE customers NEW
   IF !DBSEEK(nID)
      APPEND BLANK
      REPLACE ID WITH nID, ;
              Name WITH "Jane", ;
              Email WITH "ja...@site.com", ;
              Active WITH .T.
      ? "Customer added."
   ELSE
      ? "Customer already exists."
   ENDIF
   USE
   RETURN

---

Best Practices for Database Work

1. Always CLOSE your DBF files.
2. Use indexes when searching repeatedly.
3. Avoid unnecessary PACK on shared files.
4. Use USE ... NEW to prevent alias conflicts.
5. Validate input before writing.

---

Quick Reference: DBF Command Cheatsheet

USE customers NEW SHARED
SET INDEX TO custname
APPEND BLANK
REPLACE Name WITH "Bob"
SKIP
LOCATE FOR Email == "b...@site.com"
DELETE
PACK

---

By mastering Harbour's database programming capabilities, you now control the heart of many business applications—data. Like a lighthouse logbook filled with every detail of each passing ship, your applications can now safely record, retrieve, and manage vital information.
--------------------------------------------------------------

HTH,
Grigory

понедельник, 9 июня 2025 г. в 09:55:44 UTC+2, priadi andika:

gfil...@gmail.com

unread,
Jun 9, 2025, 5:25:05 AMJun 9
to Harbour Users
Let's continue...

--------------------------------------------------------------------------------
Chapter 11: Object-Oriented Programming (OOP)

Much like a lighthouse is composed of modular systems—beacons, lenses, gears—object-oriented programming (OOP) lets you build applications as structured components. In Harbour, OOP empowers you to organize complex logic into reusable, maintainable, and scalable units.

This chapter introduces OOP in Harbour: defining classes, working with objects, encapsulating behavior, and extending functionality through inheritance and polymorphism.

---

1. Why Use OOP in Harbour?

Object-oriented programming brings several key benefits:

* Encapsulation: Group data and behavior
* Modularity: Divide large programs into small, reusable parts
* Inheritance: Share and extend logic easily
* Polymorphism: Interface flexibility across types
* Clarity: Clean separation of concerns

> Harbour’s OOP is dynamic, class-based, and fully integrated with the language's procedural core.

---

2. Defining a Class

Use the CLASS keyword to define an object with properties (fields) and methods (functions):

CLASS Customer
   DATA Name INIT "Unknown"
   DATA Email INIT ""

   METHOD Greet()
ENDCLASS

METHOD Greet() CLASS Customer
   ? "Hello,", ::Name
   RETURN


* DATA defines a property.
* METHOD defines a function tied to the class.
* :: refers to the current instance (similar to this in other languages).

---

3. Creating and Using Objects

Instantiate classes using :New():

PROCEDURE Main()
   LOCAL oCust := Customer():New()
   oCust:Name := "Alice"
   oCust:Email := "al...@example.com"
   oCust:Greet()
   RETURN

---

4. Constructors and Destructors

You can define a New() method for custom initialization.

METHOD New(cName, cEmail) CLASS Customer
   ::Name  := cName
   ::Email := cEmail
   RETURN Self

Usage:

LOCAL oCust := Customer():New("Bob", "b...@example.com")


> Return Self so the constructor can be used inline.

---

5. Inheritance

Create a new class based on an existing one using the FROM keyword.

CLASS PremiumCustomer FROM Customer
   DATA Points INIT 0

   METHOD AddPoints(n)
   METHOD Greet()
ENDCLASS

METHOD AddPoints(n) CLASS PremiumCustomer
   ::Points += n
   RETURN

METHOD Greet() CLASS PremiumCustomer
   ? "Welcome back, premium user:", ::Name
   RETURN

You can override parent methods to specialize behavior (polymorphism).

---

6. Polymorphism

Polymorphism allows you to call the same method on different classes.

FUNCTION SayHello(oAny)
   oAny:Greet()

PROCEDURE Main()
   LOCAL o1 := Customer():New("Joe", "j...@x.com")
   LOCAL o2 := PremiumCustomer():New("Anna", "an...@x.com")

   SayHello(o1)  // uses Customer:Greet()
   SayHello(o2)  // uses PremiumCustomer:Greet()
   RETURN

This makes your code extensible without changing the core logic.

---

7. Static and Class-Level Methods

Use CLASS FUNCTION for utility methods not tied to instances.

CLASS MathUtil
   CLASS FUNCTION Square(n)
ENDCLASS

CLASS FUNCTION Square(n)
   RETURN n * n

? MathUtil:Square(5)   // 25

---

8. Visibility and Encapsulation

While Harbour does not enforce strict private/public visibility like some OOP languages, naming conventions and discipline help:

* Prefix internal fields with underscore: _nCount
* Avoid exposing internals unnecessarily
* Provide getters/setters if needed:

METHOD SetEmail(c) INLINE ::Email := Lower(c)
METHOD GetEmail() INLINE ::Email

---

9. Using Objects in Arrays or Hashes

Objects can be stored in collections like arrays or hashes.

LOCAL aCustomers := { Customer():New("Tom", "t...@a.com"), ;
                      Customer():New("Sue", "s...@b.com") }

FOR EACH oCust IN aCustomers
   oCust:Greet()
NEXT

---

10. Class-Based Architecture Example

CLASS Product
   DATA Name INIT ""
   DATA Price INIT 0.0

   METHOD New(cName, nPrice)
   METHOD Display()
ENDCLASS

METHOD New(c, p) CLASS Product
   ::Name  := c
   ::Price := p
   RETURN Self

METHOD Display() CLASS Product
   ? "Product:", ::Name, "Price: $", ::Price
   RETURN

Usage:

LOCAL o := Product():New("Laptop", 999.99)
o:Display()

---

11. Dynamic Objects and Extensibility

Harbour allows dynamic addition of methods and data at runtime using metaprogramming techniques (advanced topic).

o:NewMethod := {|| ? "I'm dynamic!" }
Eval(o:NewMethod)

---

12. Quick Reference

| Concept         | Syntax Example                      |
| --------------- | ------------------------------------|
| Define class    | CLASS MyClass ... ENDCLASS          |
| Define property | DATA Name INIT ""                   |
| Define method   | METHOD Hello() CLASS MyClass        |
| Instantiate     | o := MyClass():New()                |
| Inheritance     | CLASS Child FROM Parent             |
| Access member   | ::Name (within), o:Name (outside)   |
| Static method   | CLASS FUNCTION Utility()            |
| Polymorphism    | oAny:Greet() (dynamic dispatch)     |


---

Best Practices for OOP in Harbour

* Keep classes focused (Single Responsibility Principle)
* Initialize all fields in New()
* Avoid deep inheritance trees
* Use polymorphism instead of conditionals when possible
* Document class APIs with comments and headers

---

Final Thoughts

With object-oriented programming, you build software not just as instructions—but as intelligent, cooperative entities. Each class becomes a reliable part of the system, like a cog in the beacon’s machinery, contributing to a greater, maintainable whole.

You're no longer just scripting logic—you're crafting architecture.
-------------------------------------------------------------------------------------------------------

понедельник, 9 июня 2025 г. в 11:13:10 UTC+2, gfil...@gmail.com:

antonio....@gmail.com

unread,
Jun 9, 2025, 1:53:43 PMJun 9
to Harbour Users
A Spanish one this time

Also trying to complete the previous one

best regards

The_Harbour_Project_Final (2).pdf

antonio....@gmail.com

unread,
Jun 9, 2025, 2:24:54 PMJun 9
to Harbour Users
chapters 6 to 8
harbour_book_part2_chapters_6_8.pdf

Alain Aupeix

unread,
Jun 9, 2025, 3:19:10 PMJun 9
to harbou...@googlegroups.com, antonio....@gmail.com

Hi Antonio,

Why to talk about harbour 3.0.0 which is outdated.

I know 3.2.0 is not considered as a stable release, but I think it's about to be the case, and a few improvements have been added ...

A+
--

Alain Aupeix
Sites web : JujuLand | Pissobi-Lacassagne | Gadel
X.ubuntu 16.04 | H.arbour 3.2.0-1 (r2024-09-14 21:26) | Hw.gui 2.23-8dev (r3481) | G.ramps 5.1.2


Maurício Faria

unread,
Jun 10, 2025, 9:05:50 AMJun 10
to harbou...@googlegroups.com
Hi.
 
Time to release 3.2 as a stable version!
But this is a right of the developers team...
In the way it is now, it seams abandon-ware to outside community people.
Talked about this more than once in the past few years, but they did not agree.
Just my two cents...
Regards.
 
Maurício Faria
--
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.
Reply all
Reply to author
Forward
0 new messages