A typical Harbour Program

A Typical Harbour Program

// Menu.prg -- Display a menu and process a menu choice
// Manifest constant definitions
#define ONE 1
#define TWO 2
#define THREE 3
// File-wide variable declarations go here
PROCEDURE Main
// Local variable declarations

 LOCAL nChoice

 // Continous loop redisplays menu after each function return

 DO WHILE .T.

 // Function call to display main menu

 nChoice := MainMenu()

 // CASE structure to make function call 
 // based on return value of MainMenu()

 DO CASE

 // Function called in CASE structure are defined
 // in Database.prg, included at the end of this file

 CASE nChoice = ONE
 AddRecs()
CASE nChoice = TWO
 EditRecs() 

 CASE nChoice = THREE
 Reports() 

 OTHERWISE
 EXIT // Break out of continuos loop 

 ENDCASE

 ENDDO

RETURN // Main()

FUNCTION MainMenu( MenuChoice )
 CLEAR
 SET WRAP ON
 SET MESSAGE TO 23 CENTER

 @ 6, 10 PROMPT "Add" MESSAGE "New Account"
 @ 7, 10 PROMPT "Edit" MESSAGE "Change Account"
 @ 8, 10 PROMPT "Reports" MESSAGE "Print Account Reports"
 @ 10, 10 PROMPT "Quit" MESSAGE "Return to DOS"

 MENU TO MenuCoice

 CLEAR

RETURN MenuCoice // MainMenu() 

#include "Database.prg" // Contains generic database functions

* end of menu.prg

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

A Typical Harbour Program -- Screen shoot 2

// Database.prg
PROCEDURE AddRecs() 
 ALERT( "New Account process will run" )
RETURN // AddRecs()
PROCEDURE EditRecs() 
 ALERT( "Account changing process will run" )
RETURN // EditRecs()

PROCEDURE Reports() 
 ALERT( "Printing Account Reports Process will run" )
RETURN // Reports()

Note : A detailed explanation of this program is here :

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.