FWHMaria and oMeter

FWHMaria and oMeter

Postby Compuin » Tue Dec 28, 2021 6: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: Select all  Expand view

#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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1213
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: FWHMaria and oMeter

Postby leandro » Tue Dec 28, 2021 9:08 pm

Debes cambiar el valor al momento de ir avanzando por la consulta

Code: Select all  Expand view

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

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1481
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: FWHMaria and oMeter

Postby Compuin » Tue Dec 28, 2021 9:20 pm

Gracias

LO estoy intentando sin usar oRs, asi

Code: Select all  Expand view

#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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1213
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 77 guests