Files
harbour-core/harbour/tests/clasinit.prg
Viktor Szakats 5099fba567 2012-10-02 20:35 UTC+0200 Viktor Szakats (harbour syenar.net)
* contrib/hbamf/tests/tstendin.prg
  * contrib/hbgt/tests/test.prg
  * contrib/hbmisc/stringp.prg
  * contrib/hbmisc/tests/readfile.prg
  * contrib/hbmisc/tests/testhbf.prg
  * contrib/hbmysql/tests/test.prg
  * contrib/hbmysql/tmysql.prg
  * contrib/hbnf/doc/en/*.txt
  * contrib/hbnf/tests/*.prg
  * contrib/hbsqlit3/tests/*.prg
  * contrib/hbssl/tests/pem.prg
  * contrib/hbziparc/doc/en/hbziparc.txt
  * doc/en/objfunc.txt
  * doc/en/rdddb.txt
  * doc/en/rddmisc.txt
  * doc/en/string.txt
  * tests/clasinit.prg
  * tests/debugtst.prg
  * tests/dynobj.prg
  * tests/funcarr.prg
  * tests/inherit.prg
  * tests/objarr.prg
  * tests/objasign.prg
  * tests/stripem.prg
    * cleanups
2012-10-02 18:38:03 +00:00

63 lines
1.3 KiB
Plaintext

/*
* $Id$
*/
// Using Harbour Class HBClass
PROCEDURE Main()
LOCAL oForm := TForm():New()
LOCAL oSecond
? "What's the default oForm and calculate area"
? hb_ValToExp( oForm )
? oForm:CalcArea()
? "Set nTop to 5 and recalculate"
oForm:nTop := 5
? hb_ValToExp( oForm )
? oForm:CalcArea()
? "Create a new instance and calculate area"
oSecond := TForm():New()
? hb_ValToExp( oSecond )
? oSecond:CalcArea()
RETURN
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()
? "lets show a form from here :-)"
RETURN NIL