COMANDO READVAR EN FIVEWIN

Post Reply
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

COMANDO READVAR EN FIVEWIN

Post by karinha »

Buenas Maestro, duda:

Estoy usando MACRO SUSBSTITUCION y me genera erro al hacer esto:

Llamada de un GET y dispara para una function validadora...

Code: Select all

    IF WYC = 0
       VCOD := READVAR() //-> Cual es el comando en FIVEWIN?? -> No funciona 
    ELSE
       VCOD := "PRODU" + STRZERO( WYC, 2, 0 ) + "A"  //-> Funciona perfecto
    ENDIF

Regards, saludos
João Santos - São Paulo - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Puedes hacer lo siguiente:

Code: Select all

    REDEFINE GET aGetFat[13] VAR  &YPRODU  ID IDYPRODU PICTURE "@!"    ;
             OF oFld:aDialogs[1] UPDATE    WHEN( lPesquisa )           ;
             FONT oFont COLORS CLR_BLACK, CLR_HCYAN                    ;
             VALID PESQPRODU2( 0 ) //-> Validar o codigo do produto

   aGetFat[13]:oGet:Name = YPRODU

Code: Select all

FUNCTION ReadVar()
   LOCAL nWnd := AScan( GetAllWin(),;
                        { | oWnd | oWnd:lFocused .and. oWnd:ClassName() == "TGET" } )

RETURN If( nWnd != 0, GetAllWin()[ nWnd ]:oGet:Name, Nil )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Maestro Antonio, No funciona... Mas alguna cosa??

Code: Select all

FUNCTION PRODUTOS()

    //-> Inicializa os N£meros dos ID's - Folder 1
    IDYPRODU := 40  //-> ID's dos Get's dos Codigos do Produto

    YC := 0

    WHILE YC<9

       SYSREFRESH()

       YC      := YC+1
       YLIN    := YLIN+1
       YCC     := STRZERO(YC,2,0)+"A"
       YCAMPO  := "PRODU"+STRZERO(YC,2,0)
       YVPRODU := "VPRODU"+YCC
       YPRODU  := "PRODU"+YCC  //-> codigo do produto
       YQT     := "QT"+YCC
       YVRUN   := "VRUN"+YCC
       YTRIES  := "TRIES"+YCC
       YALICM  := "ALICM"+YCC
       YALICI  := "ALICI"+YCC
       YWALICI := "WALICI"+YCC
       YDEST   := "DEST"+YCC
       YMOVES  := "MOVES"+YCC
       YVMOVES := "VMOVES"+YCC
       YPNOME  := "PNOME"+YCC
       YWTLP   := "WTLP"+YCC
       oProdu  := "oProdu"+YCC

       IF .NOT. WALTPED

          //DO SAYCOMDT WITH YPRODU,YLIN,02,"@!"

       ELSE


          REDEFINE GET aGetFat[13] VAR  &YPRODU  ID IDYPRODU PICTURE "@K!"   ;
                   OF oFld:aDialogs[1] UPDATE    WHEN( lPesquisa )           ;
                   FONT oFont COLORS CLR_BLACK, CLR_HCYAN                    ;
                   VALID PESQPRODU2( 0 )

          //-> By Antonio Linares
          aGetFat[13]:oGet:Name := YPRODU  //-> No Funciona

          //aGetFat[13]:oGet:Name := &YPRODU  //-> No Funciona

       ENDIF

       //-> ID's - Codigo do Produto
       IDYPRODU := IDYPRODU + 1

    ENDDO

RETURN NIL
//
//-> Pesquisa o Codigo do Produto, se READVAR funcionar.
//
FUNCTION PESQPRODU2()

    PARA WYC

    IF WYC=0

       //-> Funcao READVAR, Incorporada em 03/11/2008
       // By Antonio Linares
       VCOD := READVAR()  //-> VCOD retorna vacio... ????

       ? VCOD //-> Retorna VACIO... Generando erro de VARIABLE...
    ELSE
       VCOD := "PRODU"+STRZERO(WYC,2,0)+"A"
    ENDIF

RETURN( .T. )

//-> By Antonio Linares: Puedes hacer lo siguiente: em: 03/11/2008

FUNCTION ReadVar()

   LOCAL nWnd := AScan( GetAllWin(),;
                        { | oWnd | oWnd:lFocused .and. oWnd:ClassName() == "TGET" } )

RETURN IF( nWnd != 0, GetAllWin()[ nWnd ]:oGet:Name, Nil )
//-> FIM DO PROGRAMA

Un Abrazo.

Regards, saludos.
João Santos - São Paulo - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Joao,

Siempre redefines el mismo objeto GET:

Code: Select all

REDEFINE GET aGetFat[13] ...
Deberias aumentar 13+... en cada iteración del bucle para que sean objetos distintos
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Maestro Antonio:

Code: Select all


          REDEFINE GET &oProdu     VAR  &YPRODU  ID IDYPRODU PICTURE "@K!"   ;
                   OF oFld:aDialogs[1] UPDATE    WHEN( lPesquisa )           ;
                   FONT oFont COLORS CLR_BLACK, CLR_HCYAN                    ;
                   VALID PESQPRODU2( 0, YPRODU )


          &oProdu:oGet:Name := YPRODU

          ? oProdu  //-> Hace correcto, incrementa el objecto del GET



FUNCTION PESQPRODU2( WYC, YPRODU )


    IF WYC=0

         VCOD := READVAR()

         ? YPRODU, VCOD  //-> Muestra siempre el ULTIMO Produto y no el PRIMERO.

    ENDIF

Maestro como hago para pegar el OBJETO en FOCO??
João Santos - São Paulo - Brasil
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Code: Select all


    IF WYC=0

         WFOLDER=oFld:nOption

         DO CASE
         CASE WFOLDER=1

            oCtl:=oFld:aDialogs[1]:oCtlFocus()

            //-> Asi, no funciona
            IF ( oCtl:hWnd = &oProdu:hWnd )

                msginfo('O objeto get selecionado é "+&oProdu+" que corresponde ao foco onde o cursor se encontra no momento!')

                return(.t.)

            ENDIF

            Asi:

            //Error BASE/1004  Class: 'CHARACTER' has no exported method: HWND

            IF (oCtl:hWnd = oProdu:hWnd)

                msginfo('O objeto get selecionado é "+&oProdu+" que corresponde ao foco onde o cursor se encontra no momento!')

                return(.t.)

            ENDIF

         CASE WFOLDER=2
            oCtl:=oFld:aDialogs[2]:oCtlFocus()
         CASE WFOLDER=3
            oCtl:=oFld:aDialogs[3]:oCtlFocus()
         ENDCASE
    ELSE
       VCOD := "PRODU"+STRZERO(WYC,2,0)+"A"
    ENDIF

Porfa Maestro que hago mal???

Saludos.
João Santos - São Paulo - Brasil
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Post by Daniel Garcia-Gil »

prueba esto

Code: Select all

&oProdu:bValid = GenValid( YPRODU  )

function GenValid( YPRODU )
return( {|| PESQPRODU2( YPRODU ) } )

FUNCTION PESQPRODU2( YPRODU )
     ? &YPRODU, YPRODU
RETURN .T.

espero te sirva de camino
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

mcfox wrote:prueba esto

Code: Select all

&oProdu:bValid = GenValid( YPRODU  )

function GenValid( YPRODU )
return( {|| PESQPRODU2( YPRODU ) } )

FUNCTION PESQPRODU2( YPRODU )
     ? &YPRODU, YPRODU
RETURN .T.

espero te sirva de camino

Gracias Daniel, Voy testar.

Regards, saludos.
João Santos - São Paulo - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

João,

Aqui tienes un ejemplo completo y funcionando:

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oDlg, aValues[ 4 ], n, oGet
   
   SET KEY VK_F2 TO ShowInfo()

   DEFINE DIALOG oDlg RESOURCE "Test" TITLE "Pulsa F2 para ReadVar()"

   for n = 1 to 4
      aValues[ n ] = PadL( Str( n ), 20 )
      oGet = TGet():Redefine( 100 + ( n - 1 ) * 10, GenSetGet( aValues, n ), oDlg )
      oGet:oGet:Name = "aValues[" + AllTrim( Str( n ) ) + "]"
   next

   ACTIVATE DIALOG oDlg CENTERED

return nil

function GenSetGet( aValues, n )

return bSETGET( aValues[ n ] )

function ShowInfo()

   MsgInfo( ReadVar() )
   
return nil   

function ReadVar()

   local nWnd := AScan( GetAllWin(),; 
                        { | oWnd | oWnd:lFocused .and. oWnd:ClassName() == "TGET" } ) 

return If( nWnd != 0, GetAllWin()[ nWnd ]:oGet:Name, Nil )
test.rc

Code: Select all

test DIALOG 119, 76, 194, 119
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Test"
FONT 8, "MS Sans Serif"
{
 EDITTEXT 100, 53, 10, 108, 14
 EDITTEXT 110, 53, 29, 108, 14
 EDITTEXT 120, 53, 48, 108, 14
 EDITTEXT 130, 53, 67, 108, 14
 DEFPUSHBUTTON "OK", IDOK, 72, 96, 50, 14
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
giba_f
Posts: 18
Joined: Thu Sep 21, 2006 1:51 am
Location: Brasil
Contact:

Post by giba_f »

Antonio Linares wrote:Puedes hacer lo siguiente:

Code: Select all

    REDEFINE GET aGetFat[13] VAR  &YPRODU  ID IDYPRODU PICTURE "@!"    ;
             OF oFld:aDialogs[1] UPDATE    WHEN( lPesquisa )           ;
             FONT oFont COLORS CLR_BLACK, CLR_HCYAN                    ;
             VALID PESQPRODU2( 0 ) //-> Validar o codigo do produto

   aGetFat[13]:oGet:Name = YPRODU

Code: Select all

FUNCTION ReadVar()
   LOCAL nWnd := AScan( GetAllWin(),;
                        { | oWnd | oWnd:lFocused .and. oWnd:ClassName() == "TGET" } )

RETURN If( nWnd != 0, GetAllWin()[ nWnd ]:oGet:Name, Nil )
e, como fazer igual pro ComboBox ??

Obrigado
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Giba,

> e, como fazer igual pro ComboBox ??

Puedes usar oComboBox[ ... ]:Cargo en vez de oGet[ ... ]:oGet:Name
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Buenos dias...

Después posto la respuesta correcta.

Abrazos y muchas gracias.
João Santos - São Paulo - Brasil
Post Reply