Files
harbour-core/harbour/tests/clasinit.prg
Viktor Szakats 4d4bb8e11c 2008-07-28 20:41 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* tests/ainstest.prg
   * tests/array16.prg
   * tests/arrays.prg
   * tests/atest.prg
   * tests/clasinit.prg
   * tests/classch.prg
   * tests/classes.prg
   * tests/dates.prg
   * tests/db_brows.prg
   * tests/ddate.prg
   * tests/debugtst.prg
   * tests/dynobj.prg
   * tests/files.prg
   * tests/gfx.prg
   * tests/inline.prg
   * tests/keywords.prg
   * tests/objects.prg
   * tests/onidle.prg
   * tests/readhrb.prg
   * tests/rtfclass.prg
   * tests/speed.prg
   * tests/switch.prg
   * tests/test_all.prg
   * tests/testbrw.prg
   * tests/testcgi.prg
   * tests/testcls.prg
   * tests/testget.prg
   * tests/testhtml.prg
   * tests/testidle.prg
   * tests/testinit.prg
   * tests/testntx.prg
   * tests/testpers.prg
   * tests/testrdd2.prg
   * tests/teststr.prg
   * tests/tstblock.prg
   * tests/tstmacro.prg
   * tests/videotst.prg
   * tests/vidtest.prg
   * tests/wcecon.prg
     * Cleanups. SVN header, '=' operator usage.
2008-07-28 18:43:42 +00:00

63 lines
1.4 KiB
Plaintext

//
// $Id$
//
// Using Harbour Class HBClass
function Main()
local oForm := TForm():New()
local oSecond
QOut( "What's the default oForm and calculate area" )
Debug( oForm )
QOut( oForm:CalcArea() )
QOut( "Set nTop to 5 and recalculate" )
oForm:nTop := 5
Debug( oForm )
QOut( oForm:CalcArea() )
QOut( "Create a new instance and calculate area" )
oSecond := TForm():New()
Debug( oSecond )
QOut( oSecond:CalcArea() )
return nil
function TForm()
static oClass
if oClass == nil
oClass := HBClass():New( "TFORM" ) // starts a new class definition
oClass:AddData( "cName" ) // define this class objects datas
oClass:AddData( "nTop" , 10 )
oClass:AddData( "nLeft" , 10 )
oClass:AddData( "nBottom", 20 )
oClass:AddData( "nRight" , 40 )
oClass:AddMethod( "New", @New() ) // define this class objects methods
oClass:AddMethod( "Show", @Show() )
oClass:AddInline( "CalcArea", ;
{|self| ( ::nRight - ::nLeft ) * ( ::nBottom - ::nTop ) } )
oClass:Create() // builds this class
endif
return oClass:Instance() // builds an object of this class
static function New()
local Self := QSelf()
return Self
static function Show()
local Self := QSelf()
QOut( "lets show a form from here :-)" )
return nil