Newsgroup: it.comp.lang.vo-clipper
Titolo: Classi in Harbour o xHarbour

Ciao a tutti,
qualcuno ha utilizzato le classi in Harbour o xHarbour ? Mi serve un
esempio.
Aiuto EMG !!!!!
Ciao
Paolo Russignan

 Aiuto EMG !!!!!
Questa č una classe che avevo iniziato a scrivere per usare piů comodamente i 
recordset ADO:
#include "Hbclass.ch"
CLASS TRecordset
    CLASSDATA cConnectionString
    DATA oRs
    DATA cQuery
    CONSTRUCTOR New( cQuery, cConnStr, nCursorType, nLockType )
    DESTRUCTOR End() INLINE ::oRs := NIL
    METHOD Requery( cQuery, cConnStr, nCursorType, nLockType )
    METHOD Close() INLINE ::oRs:Close()
    METHOD RecordCount() INLINE ::oRs:RecordCount
    METHOD AbsolutePosition() INLINE ::oRs:AbsolutePosition
    METHOD Move( nSkip )  INLINE IF( ::oRs:RecordCount > 0, ::oRs:Move( 
nSkip ), )
    METHOD MoveFirst()    INLINE IF( ::oRs:RecordCount > 0, 
::oRs:MoveFirst(), )
    METHOD MoveLast()     INLINE IF( ::oRs:RecordCount > 0, 
::oRs:MoveLast(), )
    METHOD MovePrevious() INLINE IF( ::oRs:RecordCount > 0, 
::oRs:MovePrevious(), )
    METHOD MoveNext()     INLINE IF( ::oRs:RecordCount > 0, 
::oRs:MoveNext(), )
    METHOD Find( cWhere ) INLINE ::oRs:Find( cWhere )
    METHOD BOF() INLINE ::oRs:BOF
    METHOD EOF() INLINE ::oRs:EOF
    METHOD FieldCount() INLINE ::oRs:Fields:Count
    METHOD FieldName( xField ) INLINE ::oRs:Fields( xField ):Name
    METHOD FieldType( xField ) INLINE ::oRs:Fields( xField ):Type
    METHOD FieldSize( xField ) INLINE ::oRs:Fields( xField ):DefinedSize
    METHOD Get( xField )
    METHOD Put( xField, xValue )
    METHOD AddNew() INLINE ::oRs:AddNew()
    METHOD Update() INLINE ::oRs:Update()
    METHOD Delete() INLINE ::oRs:Delete()
ENDCLASS
METHOD New( cQuery, cConnStr, nCursorType, nLockType ) CLASS TRecordset
    DEFAULT cConnStr    := ::cConnectionString
    DEFAULT nCursorType := adOpenKeyset
    DEFAULT nLockType   := adLockOptimistic
    ::oRs = CREATEOBJECT( "ADODB.Recordset" )
    #define adUseClient 3
    ::oRs:CursorLocation = adUseClient
    ::oRs:Open( cQuery, cConnStr, nCursorType, nLockType )
    ::cQuery = cQuery
    RETURN Self
METHOD Requery( cQuery, cConnStr, nCursorType, nLockType ) CLASS TRecordset
    DEFAULT cQuery      := ::cQuery
    DEFAULT cConnStr    := ::cConnectionString
    DEFAULT nCursorType := adOpenKeyset
    DEFAULT nLockType   := adLockOptimistic
    ::oRs:Close()
    ::oRs:Open( cQuery, cConnStr, nCursorType, nLockType )
    RETURN NIL
METHOD Get( xField ) CLASS TRecordset
    LOCAL xValue, cType, nSize
    IF ::oRs:RecordCount > 0
        xValue = ::oRs:Fields( xField ):Value
    ENDIF
    cType  = GETTYPE( ::FieldType( xField ) )
    nSize  = ::FieldSize( xField )
    DO CASE
        CASE VALTYPE( xField ) = "C" .AND. UPPER( xField ) = "ID"
            IF xValue = NIL; xValue = 0; ENDIF
            RETURN xValue
        CASE cType = "C"
            IF xValue = NIL; xValue = ""; ENDIF
            RETURN PADR( xValue, nSize )
        CASE cType = "N"
            IF xValue = NIL; xValue = 0; ENDIF
            RETURN xValue
        CASE cType = "D"
            IF xValue = NIL; xValue = CTOD( "" ); ENDIF
            RETURN xValue
        CASE cType = "L"
            DO CASE
                CASE xValue = NIL
                    xValue = .F.
                CASE xValue = 0
                    xValue = .F.
                CASE xValue = -1
                    xValue = .T.
                CASE xValue = 1
                    xValue = .T.
            ENDCASE
            RETURN xValue
        CASE cType = "M"
            IF xValue = NIL; xValue = ""; ENDIF
            RETURN xValue
    ENDCASE
    RETURN NIL
METHOD Put( xField, xValue ) CLASS TRecordset
    ::oRs:Fields( xField ):Value = xValue
    RETURN NIL
EMG
--
EMAG Software Homepage:     
http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: 
http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: 
http://www.emagsoftware.it/tbosg
The EMG Music page:         
http://www.emagsoftware.it/emgmusic
 

 ha scritto nel
messaggio news:44e341d6$0$30247$4faf...@reader1.news.tin.it...
