FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour FWHMaria and oMeter
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
FWHMaria and oMeter
Posted: Tue Dec 28, 2021 06:33 PM
Hello forum

I'm trying to use FWHMaria and oMeter unsuccessfully.

If someone has created it before and can give me an orientation, I appreciate it.

Code (fw): Select all Collapse
#include "FiveWin.ch"

REQUEST DBFCDX
   
function Export()
   local cHost      := "127.0.0.1"
   local cUser      := "root"
   local cPassword  := ""
   local oCn, oRs, nSecs, uRet, cTable, aTables
   local cDb        := "COMP04"
   local oDlg, oMeterR     
         
   ? "Connect to Server"
   FWCONNECT oCn HOST cHost USER cUser PASSWORD cPassword
       if oCn == nil
        ? "Connect Fail"
   return nil
        else
   endif
       
   if oCn != nil

      ? "Selecting database " + cDb, "Create if new"
      if Empty( oCn:ListDbs( cDb ) )
         oCn:CreateDB( cDb, "latin1" )
      endif
      oCn:SelectDB( cDb )
      ? "Connected to " + oCn:CurrentDB()

      aTables := HB_dirScan( ".\", "*.dbf", "A" )

      oRs := oCn:RowSet( aTables )

      ?oRs:LastRec()

      for each cTable in  aTables //{ "customer.dbf", "states.dbf" }

         if ! oCn:TableExists( cFileNoExt( cTable[ 1 ] ) )
            //ImportFromDBF( cDbfName, nil, nil, nil, nil, .F. ) // 5th param .F. suppresses creation of AutoInc field ID
            nSecs := Seconds()
               uRet := oCn:ImportFromDBF( cTable[ 1 ], nil, nil, nil, nil, .F.  )
            nSecs := Seconds() - nSecs

            @ 2, 2 METER oMeter VAR nActual TOTAL 50 OF oDlg SIZE 135, 12
            
            oMeterR:Set(oRs:RecCount())

         endif
      next  

   endif

   ? "IMPORTACION FINALIZADA"

   oCn:Close()

return nil

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: FWHMaria and oMeter
Posted: Tue Dec 28, 2021 09:08 PM
Debes cambiar el valor al momento de ir avanzando por la consulta

Code (fw): Select all Collapse
oMeterR:Set(oRs:RecCount()) // este metodo oRs:RecCount(), retorna el total de registros, por eso no se debe notar que avanza
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: FWHMaria and oMeter
Posted: Tue Dec 28, 2021 09:20 PM
Gracias

LO estoy intentando sin usar oRs, asi

Code (fw): Select all Collapse
#include "FiveWin.ch"

REQUEST DBFCDX
   
function MAIN()
   local cHost      := "127.0.0.1"
   local cUser      := "root"
   local cPassword  := ""
   local oCn, uRet, cTable, aTables
   local cDb        := "COMP04"
   local oDlg, oMeter, nActual:=0 
         
   ? "Connect to Server"
   FWCONNECT oCn HOST cHost USER cUser PASSWORD cPassword
       if oCn == nil
        ? "Connect Fail"
   return nil
        else
   endif
       
   if oCn != nil

      ? "Selecting database " + cDb, "Create if new"
      if Empty( oCn:ListDbs( cDb ) )
         oCn:CreateDB( cDb, "latin1" )
      endif
      oCn:SelectDB( cDb )
      ? "Connected to " + oCn:CurrentDB()

      aTables := HB_dirScan( ".\", "*.dbf", "A" )
      
      nActual:=Len(aTables)

      for each cTable in  aTables //{ "customer.dbf", "states.dbf" }

         IF ! oCn:TableExists( cFileNoExt( cTable[ 1 ] ) )
            //ImportFromDBF( cDbfName, nil, nil, nil, nil, .F. ) // 5th param .F. suppresses creation of AutoInc field ID
         
         DEFINE DIALOG oDlg FROM 1, 1 TO 12, 44 ;
            TITLE "Testing the Meter controls"  
          
            @ 2, 2 METER oMeter VAR nActual TOTAL 100 OF oDlg SIZE 135, 12
            
            uRet := oCn:ImportFromDBF( cTable[ 1 ], nil, nil, nil, nil, .F.  )
            
            oMeter:Set( nActual + aTables[ x ][ 1 ] )
          
         ACTIVATE DIALOG oDlg CENTERED
         
         ENDIF
      
      NEXT  

   endif

   ? "IMPORTACION FINALIZADA"

   oCn:Close()

return nil


Creo que seria mejor usar un array pero no tengo mucha experiencia con ellos

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Continue the discussion