Files
harbour-core/harbour/tests/testdecl.prg
Ron Pinkas 2d1a852803 2000-09-02 09:00 UTC+0800 Ron Pinkas <ron@profit-master.com>
* hb_slex.bc
     * Synchronized with makefile.bc

   * include/hbclass.ch
     + Added: [AS <type>] optional clause to all Methods/Messages syntax.
     + Added directives to generate class declaration from same class creation code.

   * include/hbcomp.h
   * source/compiler/harbour.c
     + Added: char hb_comp_cDataListType;

   * source/compiler/harbour.l
     + Added support for new _HB_CLASS and _HB_MEMBER alternate class declaration syntax.

   * source/macro/macro.slx
     ! Moved .T., .Y., .F., and, .N. from self contained words to words.

   * source/compiler/harbour.slx
     ! Moved .T., .Y., .F., and, .N. from self contained words to words.
     + Added support for new _HB_CLASS and _HB_MEMBER alternate class declaration syntax.

   * source/compiler/harbour.y
     ! Improved definition of formal and optional paramter lists.
     + Added support for alternate class declaration syntax:
       _HB_CLASS ClassName
       _HB_MEMBER { [AS ...] Var1, VarN }
       _HB_MEMBER MethodName( [ [OPTIONAL] [@]FormalParam [AS ...] | @FunPointer() ] ) [ AS ... ]
       /* This syntax allows the class declaration to be on multiple seperated lines (needed to allow utilization of class creation code.)
          Tokens _HB_CLASS & _HB_MEMBER are not final, until some discussion with Ryszard. */

   * source/compiler/hbpcode.c
     * Completed classes strong type support for adaptive type variable.

   * source/rtl/tlabel.prg
   * source/rtl/treport.prg
     ! Corrected typos: AS {} -> INIT {} AS ARRAY, AS .T. -> INIT .T. AS LOGICAL etc..

   * tests/testdecl.prg
     * Changed to demonstrate class creation used as declaration.

   * utils/hbtest/hbtest.prg
     * Changed DBFNTX -> DBFCDX (was not working because DBFNTX is disabled.
2000-09-02 16:30:36 +00:00

67 lines
1.2 KiB
Plaintext

// Test for DECLARE statement
// $Id$
//
#include "hbclass.ch"
#TRANSLATE AS NEW <ClassName> => AS CLASS <ClassName> := <ClassName>():New()
DECLARE nMyFun() AS NUMERIC
/*
DECLARE MyClass ;
NEW AS CLASS MyClass ;
While AS String ;
cVar AS String
*/
DECLARE MyFun( Var1 AS STRING, OPTIONAL Var1 ) AS LOGICAL
DECLARE SomeFunc( OPTIONAL SomeVar AS STRING )
//DECLARE SomeFunc( OPTIONAL SomeVar AS STRING, OPTIONAL OtherVar )
CLASS MyClass
METHOD New() Constructor
VAR WHile AS STRING
VAR cVar AS STRING
END CLASS
INIT Function Main()
MEMVAR Var1, Var2, aVar
MEMVAR Var3, aVar5, aVar8, Var7
LOCAL MyObj AS NEW MyClass
DECLARE Var1
DECLARE Var2 := 2
DECLARE aVar[2]
DECLARE Var3 := 'Var9', Var4, aVar5[1]
DECLARE Var6, Var7:=7, aVar8[8]
DECLARE Var9 AS STRING
DECLARE &var3
DECLARE &Var3.
DECLARE &Var3. ; DECLARE &Var3.&Var3
DECLARE &Var3.var3
DECLARE Var3&Var3
DECLARE Var3&Var3.
DECLARE Var3&Var3&Var3
M->Var1 := nMyFun()
? M->Var1
? M->Var2
M->aVar[1] := 'Array Element'
? M->aVar[1]
MyObj:cVar := 'Hello'
? MyObj:cVar
RETURN NIL
METHOD New() CLASS MyClass
RETURN Self
Function nMyFun()
RETURN 1