translation to..Tdatabase

translation to..Tdatabase

Postby Silvio.Falconi » Tue Sep 03, 2019 2:59 pm

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

Code: Select all  Expand view  RUN

     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  Expand view  RUN
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 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: translation to..Tdatabase

Postby ukoenig » Wed Sep 04, 2019 9:43 am

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  Expand view  RUN

#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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests