TO James Bott : command for tdata

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

TO James Bott : command for tdata

Post by Silvio.Falconi »

Dear James ( or Timm)
I wish Know if these commands ( run good with fwh Tdatabase) run with your Tdata

//DELETE aLL RECORDS and save an array ocallind deleted records
this save on dbf an array and call all delete records, run with tdatabase but with tdata I have problems

Code: Select all

 
oStruttura:Gotop()
        Do While .not. oStruttura:eof()
           oStruttura:delete()
        oStruttura:skip()
       EndDo
       oStruttura:Gotop()

// CALL delete records
  SET DELETED  ON
        cFieldList:="cella,x,y,elemento,desc,settore,attivo"
        //nuova recupera i record cancellati
          oStruttura:SetOrder( 0 )
          oStruttura:GoTo( 1 )
          oStruttura:ArrayToDBF( atempDbf, cFieldList, nil, .t., .t. )
 




EXEC COMMAND (method Exec of Tdatabase

sample :

Code: Select all

 
 oReservation:setorder(1)
    oReservation:Exec( < ||
    SET FILTER TO AllTrim( FIELD->TYPE ) = AllTrim( cTypeRoom ) .and. FIELD->NUM = nElemento ;
   .AND. ( dDataIniziale <= FIELD->CHECK_OUT .AND. dDataFinale >= FIELD->CHECK_IN )
   return nil
   > )
   oReservation:gotop()
 
thanks
Last edited by Silvio.Falconi on Tue May 28, 2019 7:45 am, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: TO JAmes Bott : command for tdata

Post by TimStone »

I'm sorry but I do not understand the code or the objective.

First you go through and delete all of teh records.

Then you turn SET DELETED ON which means you essentially have an empty database.

Next you SetOrder to 0 ( no index ) but you never told it to use an index.

Then you take the database object and call an array to it.

I'm sorry, but I just don't understand what you are trying to do here. Perhaps I'm just too tired because I spent the day working on the playhouse for my grandkids.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TO JAmes Bott : command for tdata

Post by nageswaragunupudi »

Mr. Silvio

What is the purpose of this post? You have both TData and TDatabase. You can test yourself.

TData is a class derived from TDatabase. So, in all probability, this should work with TData also.

In some cases, the functionality of TData may be different from TDatabase. That is where Mr. James Bott has overridden some methods with his own. Wherever he did that, he must have some valid reasons for it.

In my view, TData is a safe class and used successfully by many programmers.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO JAmes Bott : command for tdata

Post by Silvio.Falconi »

Nages,Because some pieces of my application were written with the tdata class and now I find myself in serious difficulty because I should rewrite the whole source. So I tried to see if with the tdata class I could use those passages written with the tdatabase class such as the recall of the deleted record or the execution of blocks
When i build an application i build before many small tests to try and then I insert all these pieces into my application :I saw I had some prg with tdatabase and others with tdata.
So I ask to james or to timm if some commands are compatible with tdata and viceversa for a sample now I have a source code wrote with tdata ..when I try to converte it into tdatabase i have hard problems.
I have only few source written with tdata
I 'm thinking to create 2 release one with tdata and one with tdatabase to see wich release work good

I hope I answered to all questions
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TO JAmes Bott : command for tdata

Post by nageswaragunupudi »

I am not getting into your logic.
Your main question is whether the two methods ArrayToDBF() and Exec() work with TData.
I do not know TData and never used it, but still, I strongly think both these methods will work with TData also. Try it
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO JAmes Bott : command for tdata

Post by Silvio.Falconi »

Nages,
I tried another piece of source search on this forum a topic "problem with tdatabase" where Uwe answered me.
The source i insert on first message run ok with tdata
But not with tdatabase . Then i resolved with the help of Uwe.

This to say to you there are differences from tdata to tdatabase and some funcs can not run ok with tdatabase
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TO JAmes Bott : command for tdata

Post by nageswaragunupudi »

I posted the correct syntax for four methods of appending in that post.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO JAmes Bott : command for tdata

Post by Silvio.Falconi »

I saw ...

the Exec Method run also with tdata

I wish resolve the problem of these function
dbfToArray
ArrayToDBF

do you remember the test where I need to make an order and move the record to another position ?


With tdata I have problems ( not run) but It not run also with tdatabase

Image



as you can see on the picture the "Ombrellone " on first xbrowse is on the first position

on xbrowse num. 2 ( big) I move the record to end but the field ELOrdine is not changed

if I move a line he had to change the number and instead he has never changed
always remaining 1



Version for tdatabase


this is the code ( with tdatabase)

Code: Select all

 

#include "fivewin.ch"

REQUEST DBFCDX

static cPath

Function test()
Local oDlg,oElementi,oGrid
Local aBrowse

     cPath  := cFilePath(GetModuleFileName( GetInstance() ))  + "Data\"


 
   oElementi := TDatabase():Open( ,cPath+  "ELEMENTI", "DBFCDX", .T. )
   oElementi:SetOrder( 1 )
   oElementi:GoTop()

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 400, 280 PIXEL;
        FONT oFont TITLE "Elements"



 aBrowse   := { { "ELATTIVO",  i18n("Attivo"),,               80, },;
                  { "ELNOME",    i18n("Descrizione elemento"),, 80, },;
                  { "",          i18n("Colore "),,              80, },;
                  { "ELCOLORE",  i18n("Descr. Colore"),,        80, },;
                  { "ELORDINE",  i18n("Ordine"),,               80, },;
                  { "ELLOCK",    i18n("Bloccato"),,             200,} }



 @0,5 XBROWSE oGrid  ;
           SIZE 180,100 PIXEL;
           OF oDlg ;
           DATASOURCE oElementi COLUMNS aBrowse

 WITH OBJECT  oGrid
 :nClrBorder := CLR_GRAY
                      :nMarqueeStyle       := MARQSTYLE_HIGHLWIN7
                      :lHscroll            := .F.
                      :l2007               := .F.
                      :l2015               := .T.
                      :nStretchCol         := STRETCHCOL_WIDEST
                      :lAllowRowSizing     := .F.
                      :lAllowColSwapping   := .F.
                      :lAllowColHiding     := .F.
                      :lRecordSelector     := .F.
                      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
                      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
                      :nRowDividerStyle    := LINESTYLE_NOLINES
                      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
                      :CreateFromCode()
                   END

             @ 112,2 BTNBMP  PROMPT "Order"   SIZE 40,20 LEFT PIXEL OF oDlg ;
      ACTION Ordine_Elementi(oGrid,oElementi)

   activate dialog oDlg
   return nil


//----------------------------------------------------------------------------//

function Ordine_Elementi(oGrid,oElementi)

   local oDlg, oBrw, oFont
   local cSwapFields:="ELNUMERO,ELORDINE,ELNOME,ELCOLORE,ELATTIVO,ELIMGLIB,ELIMGOCC,ELIMGALT,ELLOCK"


     oElementi:setorder(0)
     oElementi:gotop()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 900,300 PIXEL TRUEPIXEL FONT oFont;
   TITLE "ELEMENTI.DBF"


  @ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oElementi AUTOCOLS ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nMarqueeStyle       := MARQSTYLE_HIGHLROW
      :AutoFit()
      :SetChecks()
      :bChange          := { || oDlg:AEvalWhen() }
      //
      :CreateFromCode()
   END


   @ 15, 20 BUTTON "ADD"  SIZE 100,40 PIXEL OF oDlg ACTION AddRec( oBrw )
   @ 15,240 BUTTON "UP"   SIZE 100,40 PIXEL OF oDlg ;
      WHEN oBrw:KeyNo > 1 ;
      ACTION SwapRec( oBrw, VK_UP, cSwapFields )
   @ 15,350 BUTTON "DOWN" SIZE 100,40 PIXEL OF oDlg ;
      WHEN oBrw:KeyNo < oBrw:nLen ;
      ACTION SwapRec( oBrw, VK_DOWN, cSwapFields )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

//---------------------------------------------------------------------------------------------//

static function SwapRec( oBrw, nKey, cList )

   local nRec, aRows

   WITH OBJECT oBrw:oDbf
      if nKey == VK_UP
        :Skip( -1 )
        if :Bof()
           :GoTop()
        else
           nRec     := :RecNo()
           aRows    := :DbfToArray( cList, nil, nil, 2 )
           :GoTo( nRec )
           if Len( aRows ) == 2
              AINS( aRows, 1, aRows[ 2 ] )
              :ArrayToDBF( aRows, cList, nil, .T. )
              :GoTo( nRec )
           endif
        endif
     elseif nKey == VK_DOWN
        nRec     := :RecNo()
        aRows    := :DbfToArray( cList, nil, nil, 2 )
        :GoTo( nRec )
        if Len( aRows ) == 2
           AINS( aRows, 1, aRows[ 2 ] )
           :ArrayToDBF( aRows, cList, nil, .T. )
           :GoTo( nRec )
           :Skip( 1 )
        endif
     endif
   END

   oBrw:Refresh()
   oBrw:SetFocus()

return nil

//-----------------------------------------------------------------------------------------------//

static function AddRec( oBrw )

   local oRec  := oBrw:oDbf:Record( .t. )

   oRec:oBrw   := oBrw
   oRec:SetDefault( "ELORDINE", { || oBrw:oDbf:LastRec() + 1 }, .F. )
   oRec:Edit()

return nil

//-----------------------------------------------------------------------------------------------//

Function BuildDbf()

   field ID,NAME,ORDINE

   local oDbf
   local aCols       := { ;
                            { "ELNUMERO"   , "C",    2, 0 },; //NUMERO
                            { "ELORDINE"   , "N",    2, 0 },; //ORDINE
                            { "ELNOME"     , "C",   30, 0 },;
                            { "ELCOLORE"   , "C",   30, 0 },;
                            { "ELATTIVO"   , "L",    1, 0 },;
                            { "ELIMGLIB"   , "C",  120, 0 },;
                            { "ELIMGOCC"   , "C",  120, 0 },;
                            { "ELIMGALT"   , "C",  120, 0 },;
                            { "ELLOCK"     , "L",    1, 0 }}

Local aData  := { ;
 {"01",1,"OMBRELLONE","lightgreen",.T.,".\images\ombrellone_verde.png",".\images\ombrelloneOccupato.png",".\images\ombrellone_bianco.png",.T.}, ;
 {"02",2,"PALMA","red",.T.,".\images\palma.png",".\images\palmaOccupato.png",".\images\palma_arancio.png",.T.}, ;
 {"03",3,"CABINA","thistle",.T.,".\images\cabina.png",".\images\cabinaOccupato.png",".\images\cabina_arancio.png",.T.}, ;
 {"04",4,"TENDA","coral",.T.,".\images\tenda.png",".\images\tendaOccupato.png",".\images\tenda_blue.png",.T.}, ;
 {"05",5,"BIDONE","gainsboro",.F.,".\images\bidone.png","","",.T. }, ;
 {"06",6,"PASSERELLA A INCROCIO","burlywood",.F.,".\images\passerella_incrocio.png","","",.T. }, ;
 {"07",7,"PASSERELLA A L","cadetblue",.F.,".\images\passerella_L.png","","",.T. }, ;
 {"08",8,"PASSERELLA L DESTRA","darkgoldenrod",.F.,".\images\passerella_L_destra.png","","",.T.}, ;
 {"09",9,"PASSERELLA L SINISTRA","darkturquoise",.F.,".\images\passerella_L_sinistra.png","","",.T. }, ;
 {"10",10,"PASSERELLA L SOPRA","gold",.F.,".\images\passerella_L_sopra.png","","",.T. }, ;
 {"11",11,"PASSERELLA ORIZONTALE","whitesmoke",.F.,".\images\passerella_orizzontale.png","","",.T. }, ;
 {"12",12,"PASSERELLA A T SOPRA","deepskyblue",.F.,".\images\passerella_T_sopra.png","","",.T. }, ;
 {"13",13,"PASSERELLA A T SOTTO","deepskyblue",.F.,".\images\passerella_T_sotto.png","","",.T. }, ;
 {"14",14,"PASSERELLA VERTICALE","firebrick",.F.,".\images\passerella_verticale.png","","",.T.}, ;
 {"15",15,"PALMA ORNAMENTALE","darkkhaki",.F.,".\images\palmaC.png","","",.T. }, ;
 {"16",16,"GIOCHI","turquoise",.F.,".\images\giochi.png","","",.T. }, ;
 {"17",17,"BAGNINO","darkorchid",.F.,".\images\torretta.png","","",.T.}}


 
   oDbf  := TDatabase():Create(cPath+ "ELEMENTI.DBF", aCols, "DBFCDX", "*" )
   oDbf:ArrayToDbf( aData )
   oDbf:Close()

   RETURN NIL

//-----------------------------------------------------------------------------------//



Version for Tdata
this is the source code of the test ( but need tdata class)

Code: Select all

 

#include "fivewin.ch"

REQUEST DBFCDX



Function test()
Local oDlg,oElementi,oGrid
Local aBrowse

BuildDbf()


     oElementi:=TElementi():New()
     oElementi:setorder(1)
     oElementi:gotop()



DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 400, 280 PIXEL;
        FONT oFont TITLE "Elements"



 aBrowse   := { { "ELATTIVO",  i18n("Attivo"),,               80, },;
                  { "ELNOME",    i18n("Descrizione elemento"),, 80, },;
                  { "",          i18n("Colore "),,              80, },;
                  { "ELCOLORE",  i18n("Descr. Colore"),,        80, },;
                  { "ELORDINE",  i18n("Ordine"),,               80, },;
                  { "ELLOCK",    i18n("Bloccato"),,             200,} }



 @0,5 XBROWSE oGrid  ;
           SIZE 180,100 PIXEL;
           OF oDlg ;
           DATASOURCE oElementi COLUMNS aBrowse

 WITH OBJECT  oGrid
 :nClrBorder := CLR_GRAY
                      :nMarqueeStyle       := MARQSTYLE_HIGHLWIN7
                      :lHscroll            := .F.
                      :l2007               := .F.
                      :l2015               := .T.
                      :nStretchCol         := STRETCHCOL_WIDEST
                      :lAllowRowSizing     := .F.
                      :lAllowColSwapping   := .F.
                      :lAllowColHiding     := .F.
                      :lRecordSelector     := .F.
                      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
                      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
                      :nRowDividerStyle    := LINESTYLE_NOLINES
                      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
                      :CreateFromCode()
                   END

             @ 112,2 BTNBMP  PROMPT "Order"   SIZE 40,20 LEFT PIXEL OF oDlg ;
      ACTION Ordine_Elementi(oGrid,oElementi)

   activate dialog oDlg
   return nil


//----------------------------------------------------------------------------//

function Ordine_Elementi(oGrid,oElementi)

   local oDlg, oBrw, oFont
   local cSwapFields:="ELNUMERO,ELORDINE,ELNOME,ELCOLORE,ELATTIVO,ELIMGLIB,ELIMGOCC,ELIMGALT,ELLOCK"
   
 
     oElementi:setorder(0)
     oElementi:gotop()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 900,300 PIXEL TRUEPIXEL FONT oFont;
   TITLE "ELEMENTI.DBF"
 

  @ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oElementi AUTOCOLS ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nMarqueeStyle       := MARQSTYLE_HIGHLROW
      :AutoFit()
      :SetChecks()
      :bChange          := { || oDlg:AEvalWhen() }
      //
      :CreateFromCode()
   END


   @ 15, 20 BUTTON "ADD"  SIZE 100,40 PIXEL OF oDlg ACTION AddRec( oBrw )
   @ 15,240 BUTTON "UP"   SIZE 100,40 PIXEL OF oDlg ;
      WHEN oBrw:KeyNo > 1 ;
      ACTION SwapRec( oBrw, VK_UP, cSwapFields )
   @ 15,350 BUTTON "DOWN" SIZE 100,40 PIXEL OF oDlg ;
      WHEN oBrw:KeyNo < oBrw:nLen ;
      ACTION SwapRec( oBrw, VK_DOWN, cSwapFields )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil



static function SwapRec( oBrw, nKey, cList )

   local nRec, aRows

   WITH OBJECT oBrw:oDbf
      if nKey == VK_UP
        :Skip( -1 )
        if :Bof()
           :GoTop()
        else
           nRec     := :RecNo()
           aRows    := :DbfToArray( cList, nil, nil, 2 )
           :GoTo( nRec )
           if Len( aRows ) == 2
              AINS( aRows, 1, aRows[ 2 ] )
              :ArrayToDBF( aRows, cList, nil, .T. )
              :GoTo( nRec )
           endif
        endif
     elseif nKey == VK_DOWN
        nRec     := :RecNo()
        aRows    := :DbfToArray( cList, nil, nil, 2 )
        :GoTo( nRec )
        if Len( aRows ) == 2
           AINS( aRows, 1, aRows[ 2 ] )
           :ArrayToDBF( aRows, cList, nil, .T. )
           :GoTo( nRec )
           :Skip( 1 )
        endif
     endif
   END

   oBrw:Refresh()
   oBrw:SetFocus()

return nil


static function AddRec( oBrw )

   local oRec  := oBrw:oDbf:Record( .t. )

   oRec:oBrw   := oBrw
   oRec:SetDefault( "ELORDINE", { || oBrw:oDbf:LastRec() + 1 }, .F. )
   oRec:Edit()

return nil



Function BuildDbf()

   field ID,NAME,ORDINE

   local oDbf
   local aCols       := { ;
                            { "ELNUMERO"   , "C",    2, 0 },; //NUMERO
                            { "ELORDINE"   , "N",    2, 0 },; //ORDINE
                            { "ELNOME"     , "C",   30, 0 },;  
                            { "ELCOLORE"   , "C",   30, 0 },;  
                            { "ELATTIVO"   , "L",    1, 0 },;  
                            { "ELIMGLIB"   , "C",  120, 0 },;  
                            { "ELIMGOCC"   , "C",  120, 0 },;  
                            { "ELIMGALT"   , "C",  120, 0 },;  
                            { "ELLOCK"     , "L",    1, 0 }}

Local aData  := { ;
 {"01",1,"OMBRELLONE","lightgreen",.T.,".\images\ombrellone_verde.png",".\images\ombrelloneOccupato.png",".\images\ombrellone_bianco.png",.T.}, ;
 {"02",2,"PALMA","red",.T.,".\images\palma.png",".\images\palmaOccupato.png",".\images\palma_arancio.png",.T.}, ;
 {"03",3,"CABINA","thistle",.T.,".\images\cabina.png",".\images\cabinaOccupato.png",".\images\cabina_arancio.png",.T.}, ;
 {"04",4,"TENDA","coral",.T.,".\images\tenda.png",".\images\tendaOccupato.png",".\images\tenda_blue.png",.T.}, ;
 {"05",5,"BIDONE","gainsboro",.F.,".\images\bidone.png","","",.T. }, ;
 {"06",6,"PASSERELLA A INCROCIO","burlywood",.F.,".\images\passerella_incrocio.png","","",.T. }, ;
 {"07",7,"PASSERELLA A L","cadetblue",.F.,".\images\passerella_L.png","","",.T. }, ;
 {"08",8,"PASSERELLA L DESTRA","darkgoldenrod",.F.,".\images\passerella_L_destra.png","","",.T.}, ;
 {"09",9,"PASSERELLA L SINISTRA","darkturquoise",.F.,".\images\passerella_L_sinistra.png","","",.T. }, ;
 {"10",10,"PASSERELLA L SOPRA","gold",.F.,".\images\passerella_L_sopra.png","","",.T. }, ;
 {"11",11,"PASSERELLA ORIZONTALE","whitesmoke",.F.,".\images\passerella_orizzontale.png","","",.T. }, ;
 {"12",12,"PASSERELLA A T SOPRA","deepskyblue",.F.,".\images\passerella_T_sopra.png","","",.T. }, ;
 {"13",13,"PASSERELLA A T SOTTO","deepskyblue",.F.,".\images\passerella_T_sotto.png","","",.T. }, ;
 {"14",14,"PASSERELLA VERTICALE","firebrick",.F.,".\images\passerella_verticale.png","","",.T.}, ;
 {"15",15,"PALMA ORNAMENTALE","darkkhaki",.F.,".\images\palmaC.png","","",.T. }, ;
 {"16",16,"GIOCHI","turquoise",.F.,".\images\giochi.png","","",.T. }, ;
 {"17",17,"BAGNINO","darkorchid",.F.,".\images\torretta.png","","",.T.}}


  Local  cPath  :=  cFilePath(GetModuleFileName( GetInstance() ))  + "Data\"
   oDbf  := TDatabase():Create(cPath+ "ELEMENTI.DBF", aCols, "DBFCDX", "*" )
   oDbf:ArrayToDbf( aData )
   oDbf:Close()

   RETURN NIL

//-----------------------------------------------------------------------------------//
CLASS TXData from TData
  DATA cPath init cFilePath(GetModuleFileName( GetInstance() ))  + "Data\"  // just for testing
 // DATA cPath init oApp:cDbfPath
ENDCLASS

CLASS TElementi from TXData
   METHOD New()
ENDCLASS

METHOD New( lShared ) CLASS TElementi
   Default lShared := .t.
   ::super:New(,::cPath + "Elementi" ,, lShared)
   if ::use()
      ::setOrder(1)
      ::gotop()
   endif
   RETURN Self




Where is the error ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO JAmes Bott : command for tdata

Post by Silvio.Falconi »

any solution please ?
I wait solutions for tdatabase and tdata. thanks
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO JAmes Bott : command for tdata

Post by Silvio.Falconi »

TimStone wrote:I'm sorry but I do not understand the code or the objective.

First you go through and delete all of teh records.

Then you turn SET DELETED ON which means you essentially have an empty database.

Next you SetOrder to 0 ( no index ) but you never told it to use an index.

Then you take the database object and call an array to it.

I'm sorry, but I just don't understand what you are trying to do here. Perhaps I'm just too tired because I spent the day working on the playhouse for my grandkids.

I really don't know if you're kidding or being on purpose to not understand.
it is logical that at the beginning I opened the file o Structures with tdata

oStruttura: = TStrutture: New ()
oStructura: setordier (1)
oStructura: gotop ()


when I go to save the beach structure in the old program I used dbzap now not being able to do it because the archive is open in share I have to come up with something else.
1. then first delete all the records there are

oStruttura:Gotop()
Do While .not. oStruttura:eof()
oStruttura:delete()
oStruttura:skip()
EndDo
oStruttura:Gotop()

2. then replace them with the new date

// CALL delete records
SET DELETED ON
cFieldList:="cella,x,y,elemento,desc,settore,attivo"
//nuova recupera i record cancellati
oStruttura:SetOrder( 0 )
oStruttura:GoTo( 1 )
oStruttura:ArrayToDBF( atempDbf, cFieldList, nil, .t., .t. )


if the beach configuration is 40X20 I have 800 records so I can't add other records to the database because it would be a mistake so I have to delete them first and then replace them
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply