Autofill?

HMG en Español

Moderator: Rathinagiri

Post Reply
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Autofill?

Post by Leopoldo Blancas »

Hola a todos...

He tratado desde ayer hacer que AutoFill (TextBox) se llene automáticamente y no lo he logrado... no se puede llenar de inicio?
*---------------------------------------------
Hi all ...

I've been trying since yesterday to make AutoFill (TextBox) automatically fills and I have not been ... not be filled home?

Code: Select all


            /*
             

              AutoFill in Text Box try

              Started by Esgici
             
              Enhanced by Roberto Lopez and Rathinagiri
             
              2009.05.10
             
    */        #include "hmg.ch"
              #include "hfcl.ch"


            PROC Main()

               aCountries := HB_ATOKENS( MEMOREAD( "Countries.lst" ),   CRLF )
               
               ASORT( aCountries )                    // This Array MUST be sorted
                   
               DEFINE WINDOW frmAFTest ;
                  AT 0,0 ;
                  WIDTH  550 ;
                  HEIGHT 300 ;
                  TITLE 'AutoFill in Text Box try (BE2)' ;
                  ON INIT Llena();
                  MAIN
                 
                  ON KEY ESCAPE ACTION frmAFTest.Release
                 
                  DEFINE LABEL lblCountry
                     ROW        50
                     COL        50
                     VALUE      "Country :"
                     RIGHTALIGN .T.
                     AUTOSIZE   .T.
                  END LABEL // lblCountry
                       
                  DEFINE TEXTBOX txbCountry
                     ROW         48
                     COL         110
                     ONCHANGE    AutoFill( aCountries )
                     ONGOTFOCUS  AFKeySet( aCountries )
                     ONLOSTFOCUS AFKeyRls(  )
                  END TEXTBOX // txbCountry   
                     
               END WINDOW // frmAFTest
               
               frmAFTest.Center
               
               frmAFTest.Activate

                 
            RETU // Main()

            PROCEDURE Llena()
*               frmAFTest.txbCountry.VALUE := aCountries[1]
*               frmAFTest.txbCountry.VALUE := 'hOLA'
               SetProperty ( 'frmAFTest','txbCountry','VALUE', aCountries[1] )           
 
            RETURN NIL
Aquí quiero asignarle el valor al TextBox pero no logro hacerlo, ya hice pruebas con textbox normales y si lo hace.

Alguna idea?

Saludos
Polo
*---------------------------------------------------------------------------------------------------------------------------------------
Here I want to assign value to TextBox but I can not do it, because I tested with normal textbox does.

Any idea?

regards
Polo
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Re: Autofill?

Post by Leopoldo Blancas »

hola
User avatar
danielmaximiliano
Posts: 2646
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Autofill?

Post by danielmaximiliano »

Leopoldo Blancas wrote:hola
Polo: se te olvido adjuntar todo el ejemplo completo..
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Autofill?

Post by esgici »

Hola Polo

The "primitive" author of Autofill could not be able to predict that one day you will ask something like this ;)

Used VALUE property of TEXTBOX instead of ON INIT procedure; and Autofill.prg slightly modified.

( maybe one day even win the formality of this change )

Code: Select all

#include "hmg.ch"

PROC Main()

   aCountries := HB_ATOKENS( MEMOREAD( "Countries.lst" ),   CRLF )
   
   ASORT( aCountries )                    // This Array MUST be sorted
       
   DEFINE WINDOW frmAFTest ;
      AT 0,0 ;
      WIDTH  550 ;
      HEIGHT 300 ;
      TITLE 'AutoFill in Text Box try (BE3)' ; 
      MAIN
     
      ON KEY ESCAPE ACTION frmAFTest.Release
     
      DEFINE LABEL lblCountry
         ROW        50
         COL        50
         VALUE      "Country :"
         RIGHTALIGN .T.
         AUTOSIZE   .T.
      END LABEL // lblCountry
           
      DEFINE TEXTBOX txbCountry
         ROW         48
         COL         110
         VALUE       aCountries[1]
         ONCHANGE    AutoFill( aCountries )
         ONGOTFOCUS  AFKeySet( aCountries )
         ONLOSTFOCUS AFKeyRls(  )
      END TEXTBOX // txbCountry   
         
   END WINDOW // frmAFTest
   
   frmAFTest.Center
   
   frmAFTest.Activate

RETU // Main()
            
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC AutoFill( ;              // Auto filling text box
                aList,;       // Items list
                nCaller,;     // NIL : OnChange, 1: UP, 2: Down
                cControlName )
               
   STATIC cLastVal := '',;
          n1Result := 0
   
   LOCAL  cFrmName  := '',;
          cTxBname  := '',;
          cTxBValue := '',;     // Text Box Value
          nCarePos  := 0,;  // Text Box CaretPos
          cCurval   := ''

   cFrmName := thiswindow.name
   
   if pcount() == 3
      cTxBName := cControlName
   else
      cTxBName := this.name
   endif
   
   cTxBValue := GetProperty( cFrmName, cTxBName, "Value" )     // Text Box Value
   nCarePos  := GetProperty( cFrmName, cTxBName, "CaretPos" )  // Text Box CaretPos
   
   nCarePos := MAX( nCarePos, LEN( TRIM( cTxBValue ) ) )  
   
   IF HB_ISNIL( nCaller )
      
      IF !( cLastVal == cTxBValue )   
     

         cCurval  := LEFT( cTxBValue, nCarePos )

         IF !EMPTY( cCurval )
         
            n1Result := ASCAN( aList, { | c1 | UPPER( LEFT( c1, LEN( cCurval ) ) ) == UPPER( cCurval )} )
           
            IF n1Result > 0
               cCurval := aList[ n1Result ]
            ENDIF n1Result > 0
           
         ENDIF !EMPTY( cCurval )
         
         cLastVal := cCurval
         
         
         AF_Apply( cFrmName, cTxBName, cCurval, nCarePos )     
         
      ENDIF cLastVal # cCurval     
     
   ELSE
   
      IF n1Result > 0
     
         IF nCaller < 2
            n1Result -= IF( n1Result > 1, 1, 0 )
         ELSE
            n1Result += IF( n1Result < LEN( aList ), 1, 0 )
         ENDIF   
             
         cCurval := aList[ n1Result ]
               
         cLastVal := cCurval
         
         AF_Apply( cFrmName, cTxBName, cCurval, nCarePos )     
         
      ENDIF n1Result > 0
     
   ENDIF HB_ISNIL( nCaller )
                           
RETU // AutoFill()   
   
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC AF_Apply( ;
               cFrmName,;
               cTxBName,;
               cValue,;
               nPosit )

   SetProperty( cFrmName, cTxBName, "Value", cValue )       
   SetProperty( cFrmName, cTxBName, "CaretPos", nPosit )       

RETU // AF_Apply()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC AFKeySet(;
               aitems )
               
   Local cFrmName := thiswindow.name,;
         cTxBName := this.name
               
   ON KEY UP   OF &cFrmName  ACTION AutoFill(  aitems, 1, cTxBName )
   ON KEY DOWN OF &cFrmName  ACTION AutoFill(  aitems, 2, cTxBName )

RETU // AFKeySet()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC AFKeyRls( )

   Local cFrmName := thiswindow.name
               
   RELEASE KEY UP   OF &cFrmName
   RELEASE KEY DOWN OF &cFrmName

RETU // AFKeyRls()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Re: Autofill?

Post by Leopoldo Blancas »

Hola a todos...

Gracias por contestar...

Pero mi aplicación se trata de asignarle profesor a un grupo de una escuela, por ejemplo, al ir tecleando su nombre y guardarlos en una dbf, pero a la hora de consultar los grupos y saber a quien se le dio los grupos Autofill no permite ingresar valores guardados de una DBF, y yo pensé que era normal como un texbox..... Bueno probare su ejemplo... gracias.

Saludos
Polo
*-----------------------------------------------------------------------------------------------------------------------------------------
Hi all ...

Thanks for answering ...

But my application is a professor assign a school group, for example, to go by typing its name and save it to a dbf, but when consulting groups and know who gave Autofill groups can not enter values ​​stored in a DBF, and I thought it was normal as a texbox ..... Well proves his example ... Thank you.

regards
Polo
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Re: Autofill?

Post by Leopoldo Blancas »

Hola...

Ya probe tu ejemplo Mr. Esgici y ya me aparecen los valores, pero ahora cuando quiero modificarlos ya no hace el Autofill... correctamente...

Alguna solución ???

Saludos
Polo
*------------------------------------------------------------------------------------------------------------------------------------------------
Hello ...

Since Mr. Esgici probe your example and I already listed the values​​, but now when I want to modify the Autofill no longer ... correctly ...

Any solution???

regards
Polo
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Autofill?

Post by esgici »

Leopoldo Blancas wrote:... but now when I want to modify the Autofill no longer ...
why ?

what is the problem ?
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Autofill?

Post by esgici »

...and Autofill.prg slightly modified.
( maybe one day even win the formality of this change )...
Now, I'm not sure that my modification on AutoFill.prg is proper :?
Viva INTERNATIONAL HMG :D
Post Reply