translation to..Tdatabase

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

translation to..Tdatabase

Post by Silvio.Falconi »

I have these lines how I can to converte it into tdatabase ?

Code: Select all

     USE LOTTO2.DBF NEW ALIAS DST
       DST->( FW_ArrayToDBF( aData ) )
       DST->( DBGOTOP() )

I try with

olotto2:= TDatabase():Open( , "LOTTO2", "DBFCDX", .T. )
olotto2:setorder(1)
olotto2:gotop()
oLotto2:ArraytoDbf(aData)

but not run ok

I tried also with
Local cFieldList:="data,ruota,n1,n2,n3,n4,n5"
oLotto2:ArrayToDBF( aData, cFieldList,nil , .t., .t. )

but make errors

Code: Select all

Application
===========
   Path and name: C:\Work\Errori\lotto_tdatabase\test.Exe (32 bits)
   Size: 3,821,056 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20180217)
   FiveWin  version: FWH 19.05
   C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
   Windows version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 23 secs 
   Error occurred at: 03-09-2019, 17:21:55
   Error description: Error BASE/1001  Undefined function: ARRAYTODBF
   Args:
     [   1] = A   { ... } length: 63349
     [   2] = C   data,ruota,n1,n2,n3,n4,n5
     [   3] = U   
     [   4] = L   .T.
     [   5] = L   .T.

Stack Calls
===========
   Called from:  => ARRAYTODBF( 0 )
   Called from:  => HB_EXECFROMARRAY( 0 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:ARRAYTODBF( 1427 )
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: translation to..Tdatabase

Post by ukoenig »

Silvio,

a sample-code
maybe there is something included You can need.
1. creating the dbf
2. appending data from a array

Code: Select all

#include "FiveWin.ch"

REQUEST DBFCDX

//USE LOTTO2.DBF NEW ALIAS DST
//DST->( FW_ArrayToDBF( aData ) )
//DST->( DBGOTOP() )

//olotto2:= TDatabase():Open( , "LOTTO2", "DBFCDX", .T. )
//olotto2:setorder(1)
//olotto2:gotop()
//oLotto2:ArraytoDbf(aData)


FUNCTION MAIN()
LOCAL I, X
LOCAL aCols := {  ;
      { "MONTH",     'C',  3, 0  }, ;
      { "USAS",      'N',  4, 0  }, ;
      { "EUROS",     'N',  4, 0  }, ;
      { "ASIAS",     'N',  4, 0  }, ;
      { "USAC",      'N',  4, 0  }, ;
      { "EUROC",     'N',  4, 0  }, ;
      { "ASIAC",     'N',  4, 0  }  }

 LOCAL aData := {  { "JAN", 1000, 1200,  900,  400,  700,  400 },  ;
                     { "FEB", 1100, 1300, 1000,  500,  800,  500 },  ;
                     { "MAR", 1050, 1800, 1900,  700, 1400, 1600 },  ;
                     { "APR", 1200, 1600, 1200,  500, 1000,  800 } }

DBCREATE( "LOTTO2.DBF", aCols, "DBFCDX", .t., "DST" )
FW_ArrayToDBF( aData )
CLOSE DST

oLotto2 := TDatabase():Open( , "LOTTO2", "DBFCDX", .T. )
// CreateIndex( cFile, cTag, cKey, lUnique, lDescend, lMemory )
oLotto2:CreateIndex( "LOTTO2", "LOTTO2", "MONTH", .F. ) 
oLotto2:Gotop()

// Test appending the array once again to the existing data

I := 1
FOR I := 1 TO LEN( aData )
        oLotto2:Append() 
    X := 1
    FOR X := 1 TO oLotto2:FCount() 
        Y := aData[I][x]
        oLotto2:FieldPut( x, y )
    NEXT
    oLotto2:Save()
NEXT
xBrowse( oLotto2 )

RETURN NIL
 
regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply