Sorry, your browser doesn't support Java(tm).

 

Only a few years ago my approach to Clipper was as a classic programmer, i.e. on the basic of a modular programming. 
 
My applications was designed as usual: a driver program and many modules to accomplish program objectives.
 
Only sometimes I used to insert in applications internal clipper objects such us TBrowse. 
 
An editorial explained me about OOP and clipper capability of  OOP programming; the matter was a new free lib: oOclip. What amazing to create a new personal Class in Clipper!
 
Next I entered in Internet and one of the first web sites I visited was Oasis: so I downloaded the next version of oClip i.e. oOclip.
 
But what frustration in limit of commands even if the essential commands was available!
 
Finally oObject 2.0 by Manos Aspradakis arrived!  (    http://users.otenet.gr/~maspr/clipper.htm    )
 
This lib was complete in commands almost as commercial libs, was free and author was available for questions and suggestions. Many thanks Manos!
 
I want in this page to talk about OOP language and oObject lib, build a little example with you; obviously this is  only a modest and partial effort to deal with OOP.
 
Let's go!
 
The first thing we have to to is to create the class!
 
We can imagine to create a class for calculus i.e. a little calculator.
 
Firstly we need to create a module such us class.prg in which we must insert the class definitions.
 
The first line is to call class header:
 
#include "class.ch"
then we have to create class:

CLASS Oper

VAR nVal1
VAR nVal2
METHOD New( nVal1, nVal2 )
METHOD Add INLINE( ::nVal1 + ::nVal2 ) NOSELF
METHOD Sub INLINE( ::nVal1 - ::nVal2 ) NOSELF
METHOD Div INLINE( ::nVal1 / ::nVal2 ) NOSELF
METHOD Mult INLINE( ::nVal1 * ::nVal2 ) NOSELF
ENDCLASS
 
The code start with CLASS <name> and ends with ENDCLASS in order to delimit start and end of class definition.
 
The word VAR <variable> define the class variables.
 
METHOD are definition for class methods.
 
First method is the class constructor: in this case initialize the object with two values into the class variables i.e the four calc operators.
 
The other methods define the classic four operations in a calculator.
 
In this case has been adopted the inline definition.
(for details see oObject.lib : www.the-oasis.net/files/library/oobjec2b.zip)
 
Then we have to define the constructor method:
 
METHOD New( nVal1, nVal2 )

    IF VALTYPE( nVal1 ) == "N"
        ::nVal1 := nVal1
    ENDIF
    IF VALTYPE( nVal2 ) == "N"
        ::nVal2 := nVal2
    ENDIF
RETURN Self
 
That's all you need to define a class.
 
We beg you to note the symbol <::> i.e the send operator (see details in said oobject.lib)
 
In a separate module we can utilize your private clipper class!
 
FUNCTION Test
//to create a new object in the new class
//we assign two new operators in calculator: 4 and 5
LOCAL oObj := Oper():New( 5, 4 )

//the standard object inspector
InspectObject( oObj )

CLS
QOUT( "I verify type of variable <oObj>;" )

QOUT( VALTYPE( oObj ) )

QOUT()
QOUT()

QOUT( "I execute operations, utilizing these operators:" )

QOUT( oObj:nVal1, " and ", oObj:nVal2 )

QOUT( "" )

QOUT( "Sum :", oObj:Add )
QOUT( "Sub :", oObj:Sub )
QOUT( "Div :", oObj:Div )
QOUT( "Mult :", oObj:Mult )

QOUT( "" )

QOUT( "End of job" )

RETURN NIL
 
 
You may download here the two files in order to compile it.
Remember you need also class.lib the last lib by Manos Aspradakis.
 
 
  download example.zip
 
download class.lib
 
download Oobject.doc
 
 
 
TO the top of page                                                                                  TO home page.

 

Hosted by www.Geocities.ws

1