Page 1 of 1

How free Class Dymanic

Posted: Thu Jun 12, 2008 12:08 am
by Vladimir Zorrilla
Friends

Have function for create DATAfields

function TMyMSQuery( cCls ) ; return( MyGenClass( cCls, TMSQuery() ) )


The variable __aHCls
AAdd( __aHCls, { cClsName, __nClassH } )

the class and handle
How free


static __aHCls := {}

#include "HbClass.ch"

//---------------------------------------------------------------------------//
// Generador de clases dinamicas

function MyGenClass( cClsName, FromClass )

local n, __nClassH, __odB
local cFromClass := upper( FromClass:ClassName() )

cClsName := "TMY" + Upper( if( empty( cClsName ), ;
PadL( len( __aHCls ), 7, "0" ), Alltrim( cClsName ) ) )

if ( n := AScan( __aHCls, { |aClass| aClass[ 1 ] == cClsName } ) ) == 0
_HB_CLASS cClsName
__oDb := HBClass():New( cClsName, { cFromClass } )
__oDb:Create()
__nClassH := __oDb:hClass
AAdd( __aHCls, { cClsName, __nClassH } )
else
__nClassH := __aHCls[ n, 2 ]
endif

return( __clsInst( __nClassH ) )




//Cretae the function for deleted __aHCls the handling
//the class



Function CloseClass( oClase )
Local n,cClsName

cClsName := "TMY" + Upper( PadL( len( __aHCls ), 7, "0" ) )

if ( n := AScan( __aHCls, { |aClass| aClass[ 1 ] == cClsName } ) ) == 0
// ya se creo la clase
else
__aHCls[ n, 1 ]:=NIL
__aHCls[ n, 2 ]:=NIL
ADEL( __aHCls , n )

endif
oClase:=NIL


return( cClsName )

Posted: Thu Jun 12, 2008 6:55 am
by Antonio Linares
Vladimir,

As far as I know, there is no a way to delete a Class yet.

It could be done, but its not available yet.