From Adt to Dbf

From Adt to Dbf

Postby rubenfernandez01 » Mon Jan 18, 2021 3:46 pm

Hi friends.
How to create a dbf table from adt (ADS) table.
There's something automatic.?

Thank you.
Saludos.


Enviado desde mi Redmi Note 8 Pro mediante Tapatalk
rubenfernandez01
 
Posts: 46
Joined: Sun Sep 20, 2015 1:41 am

Re: From Adt to Dbf

Postby carlos vargas » Mon Jan 18, 2021 4:41 pm

Code: Select all  Expand view

   USE NOMTABLA0 NEW  ALIAS CTRL
   ...
   USE NOMTABLA10 NEW  ALIAS CXDT
   ...
   Adt2Dbf()
   ...
 

Code: Select all  Expand view

PROC Adt2Dbf()

   //RddSetDefault( "DBFCDX" )

   SELECT CTRL
   Mig("control")
   SELECT USUA
   Mig("usuarios")
   SELECT FERI
   Mig("feriados")
   SELECT PLAZ
   Mig("plazos")
   SELECT ZONA
   Mig("zonas")
   SELECT CIUD
   Mig("ciudades")
   SELECT GEST
   Mig("gestores")
   SELECT COBR
   Mig("cobradores")
   SELECT RUTA
   Mig("rutas")
   SELECT CLIE
   Mig("clientes")
   SELECT PROG
   Mig("programacion")
   SELECT PBAK
   Mig("programacion_bak")
   SELECT PRES
   Mig("prestamos")
   SELECT DIFE
   Mig("diferidos")
   SELECT MOVI
   Mig("movimientos")
   SELECT FLUJ
   Mig("flujos")
   SELECT MCXR
   Mig("mcobrosxruta")
   SELECT DCXR
   Mig("dcobrosxruta")
   SELECT CAJA
   Mig("caja")
   SELECT CXDI
   Mig("cobroxdia")
   SELECT CXDC
   Mig("cobroxdiac")
   SELECT CXDT
   Mig("cobroxdiat")

   RddSetDefault( "ads" )

RETURN

PROC Mig(cTabla)
   LOCAL cOldAlias := Alias()
   LOCAL xT,xT1
   LOCAL aTab
   LOCAL n,o,i

   aTab := DBStruct()

   FOR x:=1 TO Len( aTab )
      IF aTab[ x, 2 ]="D"
         aTab[ x, 3 ]=8
      ENDIF
   NEXT

   DbCreate( "d:\dbc\" + (cTabla), aTab, "DBFCDX", .T. )

   USE ( "
d:\dbc\" + (cTabla) ) ALIAS TEMP VIA "dbfcdx"

//   SELECT (cAlias)
//
//   n:=1
//   DO WHILE .T.
//      IF Empty( OrdName(n) )
//         EXIT
//      ENDIF
//      TRY
//         TEMP->( OrdCondSet((cAlias)->( OrdFor(n)),,.t.,,,, nil, nil, nil, nil,, nil, .F., .F., .F., .F.))
//         TEMP->( dbGoTop() )
//         TEMP->( ordCreate(,(cAlias)->( OrdName(n) ), (cAlias)->( OrdKey(n) ), &("
{||"+(cAlias)->( OrdKey(n) )+"}") ))
//      CATCH o
//         SELECT (cAlias)
//         ?cTabla,(cAlias)->( OrdName(n) ), (cAlias)->( ordKey(n) )
//      END
//      ++n
//   ENDDO

   SELECT ( cOldAlias )

   WaitOn("
Procesando: " + cTabla )

   i:=0
   GO TOP
   DO WHILE !Eof()
      TEMP->( DBAppend() )
      FOR x:=1 TO FCount()
         xT := FieldGet( x )
         TEMP->( FieldPut( x, xT ) )
      NEXT
      SKIP
      IF Mod( ++i, 100 )=0
         SysRefresh()
      ENDIF
   ENDDO

   WaitOff()

   TEMP->( DBCloseArea() )

   SELECT (cOldAlias)

RETURN
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1720
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: From Adt to Dbf

Postby D.Fernandez » Mon Jan 18, 2021 5:25 pm

Gracias Carlos.
Impresionante.

Estoy comenzando con Mysql y por las dudas se corta la conexion
dejo a una PC trabajando con los dbf.

Gracias, saludos.
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 464
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: From Adt to Dbf

Postby nageswaragunupudi » Tue Jan 19, 2021 4:09 pm

If the ADT file contains only fields of types "+CDLNTM", then this works
Code: Select all  Expand view

USE CUSTADT NEW VIA "ADSADT" // "ADT" in xHarbour
COPY TO CUSTDBF VIA "DBFCDX"
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: From Adt to Dbf

Postby nageswaragunupudi » Tue Jan 19, 2021 4:22 pm

Small sample converting CUSTOMER.DBF to CUSTADT.ADT and then back to CUSTDBF.DBF
Code: Select all  Expand view
#include "fivewin.ch"
#include "ads.ch"

REQUEST DBFCDX
REQUEST ADSKEYCOUNT, ADSGETRELKEYPOS, ADSSETRELKEYPOS, ADSKEYNO

static cRddADT

function main()

   local aStruct

   RddRegister( "ADS", 1 )
   AdsSetServerType( ADS_LOCAL_SERVER )

   cRddAdt  := If( AScan( RddList(), "ADSADT" ) > 0, "ADSADT", "ADT" )

   // DBF TO ADT

   aStruct  := FW_DBFSTRUCT( "CUSTOMER.DBF" )  // no need to open the dbf
   AEval( aStruct, { |a| If( a[ 2 ] == "N", a[ 3 ] += 1, ) } )

   DBCREATE( "CUSTADT.ADT", aStruct, cRddAdt, .t., "DST" )
   APPEND FROM CUSTOMER VIA "DBFCDX"
   GO TOP
   XBROWSER

   // ADT TO DBF

   GO TOP
   COPY TO CUSTDBF VIA "DBFCDX"
   CLOSE DATA

   USE CUSTDBF VIA "DBFCDX"
   XBROWSER

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: From Adt to Dbf

Postby D.Fernandez » Wed Jan 20, 2021 12:42 am

Thank you Mr. Rao.
Excellent.

I'm trying to convert a app using only Fwh with Mysql, a dbf/cdx.
Until now it's ok.

Thank you very much.

Saludos..Ruben Dario Fernandez
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 464
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 80 guests