FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Method Setget in classes
Posts: 92
Joined: Thu Feb 15, 2007 11:37 AM
Method Setget in classes
Posted: Thu Nov 13, 2008 12:17 PM
Hello, how to create a method SETGET in classes without error??!!

I declared the method below:

METHOD FieldName(cFieldName, uValue)                     SETGET


and the function below:

****************************************************************************
METHOD FieldName(cFieldName, uValue ) CLASS TDlgCadMySql
****************************************************************************
*
* Pegar o valor do campo informado da matriz
* Parametros: cFieldName
* Retorno: Variavel indefinida
*
* Autor: Anderson
* 12/11/2008 - 15:54:50
*
****************************************************************************

local Result := nil, i := 0

   if PCount() == 2
   
      //-- Set -----------------------------------------------------------//

      for i := 1 to Len(::aFields)

         if Upper(cFieldName) == ::aFields[i,1]
            ::aFields[i,2] := uValue
            exit
         end

      end//for i := 1 to Len(::aFields)
   
   else
   
      //-- Get -----------------------------------------------------------//

      for i := 1 to Len(::aFields)

         if Upper(cFieldName) == ::aFields[i,1]
            Result := ::aFields[i,2]
            exit
         end

      end//for i := 1 to Len(::aFields)

   end

return Result

/*------------------------------------------------------------------------*/


When I execute it generates mistake.

---------------------------
Unrecoverable error 9009: 
---------------------------

---------------------------
                    [ OK ]
---------------------------


Solution for this??!!
FiveWin 9.03 + xHarbour !!
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Method Setget in classes
Posted: Sat Nov 15, 2008 01:03 AM

A SETGET Method in fact creates two Methods:
METHOD Test( u ) SETGET

creates:

METHOD Test() // to retrieve a value

and

METHOD _Test( u ) // to set a value

When we do:
o:Test := value

Clipper, Harbour and xHarbour do this:
o:_Test( value ) // assignment

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion