Method Setget in classes

Method Setget in classes

Postby Anderson.OL » Thu Nov 13, 2008 12:17 pm

Hello, how to create a method SETGET in classes without error??!!

I declared the method below:

Code: Select all  Expand view
METHOD FieldName(cFieldName, uValue)                     SETGET


and the function below:

Code: Select all  Expand view
****************************************************************************
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.

Code: Select all  Expand view
---------------------------
Unrecoverable error 9009:
---------------------------

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


Solution for this??!!
FiveWin 9.03 + xHarbour !!
User avatar
Anderson.OL
 
Posts: 92
Joined: Thu Feb 15, 2007 11:37 am
Location: Itaocara - RJ - Brasil

Postby Antonio Linares » Sat Nov 15, 2008 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 102 guests