Como seria isto em xharbour ? sem o ...

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Como seria isto em xharbour ? sem o ...

Mensagem por JoséQuintas »

Aqui já falaram que usar ... era coisa de preguiçoso.... kkkk

Como faria isso dar certo sem ... ou em xharbour ?

Código: Selecionar todos

#include "hbclass.ch"

PROCEDURE Main

   LOCAL oItem

   oItem := Test():New()
   oItem:One()
   oItem:One( Nil )
   oItem:Two()
   oItem:Two( Nil )

   Inkey(0)


   RETURN

CREATE CLASS Test
   METHOD One( ... ) INLINE ::Two( ... )
   METHOD Two( x )
   ENDCLASS

METHOD Two( x ) Class test

   ? PCount(), x

   RETURN Nil
resultado desejado, que dá certo com ...

0 NIL
1 Nil
0 Nil
1 Nil

Porque ?
Porque eventualmente quero atribuir NIL, então testar Nil não serve, só contando parâmetros mesmo.
De outra forma, sem o ..., seria impossível.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Como seria isto em xharbour ? sem o ...

Mensagem por JoséQuintas »

Só de curiosidade, o uso real, que vai crescer muuuuuito...

Código: Selecionar todos

   METHOD Name( ... )              SETGET
   METHOD Handle( ... )            SETGET
   METHOD Type( ... )              SETGET
   METHOD ParentHandle( ... )      SETGET
   METHOD IsDeleted( ... )         SETGET
   METHOD AutoRelease( ... )       SETGET
   METHOD ReleaseProcedure( ... )  SETGET
   METHOD VirtualHeight( ... )     SETGET
   METHOD VirtualWidth( ... )      SETGET
   METHOD IsActive( ... )          SETGET
   METHOD NotifyIconName( ... )    SETGET
   METHOD GraphTasks( ... )        SETGET
   ENDCLASS

METHOD Index( ... )            CLASS _hmgFormclass; RETURN ::SetGet( @::_nIndex, ... )
METHOD IsDeleted( ... )        CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  65, ::_nIndex, ... )
METHOD Name( ... )             CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  66, ::_nIndex, ... )
METHOD Handle( ... )           CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  67, ::_nIndex, ... )
METHOD IsActive( ... )         CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  68, ::_nIndex, ... )
METHOD Type( ... )             CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  69, ::_nIndex, ... )
METHOD ParentHandle( ... )     CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  70, ::_nIndex, ... )
METHOD ReleaseProcedure( ... ) CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  71, ::_nIndex, ... )
METHOD NotifyIconName( ... )   CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  82, ::_nIndex, ... )
METHOD VirtualHeight( ... )    CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  91, ::_nIndex, ... )
METHOD VirtualWidth( ... )     CLASS _hmgFormclass; RETURN ::SetGetSYSDATA(  92, ::_nIndex, ... )
METHOD GraphTasks( ... )       CLASS _hmgFormclass; RETURN ::SetGetSYSDATA( 102, ::_nIndex, ... )
METHOD AutoRelease( ... )      CLASS _hmgFormclass; RETURN ::SetGetSYSDATA( 105, ::_nIndex, ... )
// another to set Nil

METHOD SetGetSYSDATA( nData, nIndex, xValue ) CLASS _hmgFormclass

   IF pCount() > 2
      _HMG_SYSDATA[ nData, nIndex ] := xValue
   ENDIF

   RETURN _HMG_SYSDATA[ nData, nIndex ]
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Como seria isto em xharbour ? sem o ...

Mensagem por JoséQuintas »

Pra quem não conhece esse uso:

SETGET é pra usar o método ("função") como se fosse variável.

Código: Selecionar todos

? oForm:Handle
oForm:Handle := 10
oForm:Handle := Nil
Ao invés de:

Código: Selecionar todos

oForm:Handle()
oForm:Handle( 10 )
oForm:Handle( Nil )
Usar uma rotina é útil, por exemplo pra validar parâmetros.
No meu caso, por enquanto foi pra reduzir a quantidade de rotina repetida.
Mas posso dividir em rotina pra validar número, string, array, etc.

Infelizmente, SETGET e INLINE não funcionam juntos, senão seria tudo na linha de cima.

Código: Selecionar todos

METHOD x SETGET INLINE ::SetGet()
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Como seria isto em xharbour ? sem o ...

Mensagem por JoséQuintas »

Faltou dizer....

Eu não sabia disso.
Perguntei no harbour-users, e Przemek mostrou a solução.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Responder