Copy or paste one record
Copy or paste one record
Hello,
Is there a method to copy or/and paste a complete record of a DBF, without knowing its structure?
Thanks a lot in advance for any help.
Is there a method to copy or/and paste a complete record of a DBF, without knowing its structure?
Thanks a lot in advance for any help.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: Copy or paste one record
Hello, see this aid program.
Is in Portuguese, but is not difficult.
http://www.pctoledo.com.br/forum/viewto ... =1&t=12062
Download:
http://www.pctoledo.com.br/forum/fileba ... 141&page=1
Regards.
Is in Portuguese, but is not difficult.
http://www.pctoledo.com.br/forum/viewto ... =1&t=12062
Download:
http://www.pctoledo.com.br/forum/fileba ... 141&page=1
Regards.
João Santos - São Paulo - Brasil
Re: Copy or paste one record
Hello Michel.
To 'copy' and ´paste' database records I use the array-field functions SCATTER & GATHER with option for field checking.
I you want, I can post them here.
HTH & regards, Euclides
To 'copy' and ´paste' database records I use the array-field functions SCATTER & GATHER with option for field checking.
I you want, I can post them here.
HTH & regards, Euclides
Re: Copy or paste one record
Here is my code :
vdata:={}
for a=1 to fcount()
aadd(vdata,fieldget(a))
next
append blank
if rlock()
for e=1 to fcount()
fieldput(e,vdata[e])
next
unlock
skip 0
else
MsgAlert("Lock error !!")
endif
vdata:={}
for a=1 to fcount()
aadd(vdata,fieldget(a))
next
append blank
if rlock()
for e=1 to fcount()
fieldput(e,vdata[e])
next
unlock
skip 0
else
MsgAlert("Lock error !!")
endif
- FranciscoA
- Posts: 1964
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: Copy or paste one record
Hi. I do Exactly as Jack do it. The Source and Target dbfs must be identical.
Regards.
Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
Re: Copy or paste one record
These functions work even if the database is not the same. Of coarse the field will not be copied if it does not exist in the other database but no error will occur.
You can also pass a record number so that you can take 1 record and update another record in the same database.
aData := scatter()
// Select other database
// Append blank or lock record
gather( aData )
You can also pass a record number so that you can take 1 record and update another record in the same database.
aData := scatter()
// Select other database
// Append blank or lock record
gather( aData )
Code: Select all
function scatter( nRecNo )
local nFldCount := fcount()
local nCounter
local aReturn
local aValues := array( nFldCount )
local aNames := array( nFldCount )
if nRecNo == nil
nRecNo := recno()
endif
goto nRecNo
for nCounter = 1 to nFldCount
aValues[ nCounter ] := fieldget( nCounter )
aNames[ nCounter ] := fieldname( nCounter )
next
Return( {aValues, aNames } )
function gather( aRecValues, nRecNo )
local nFldCount := len( aRecValues[1] )
local nCounter
if nRecNo == nil
nRecNo := recno()
endif
goto nRecNo
for nCounter = 1 to nFldCount
nFieldPos := fieldpos(aRecValues[ 2 ][ nCounter ])
if nFieldPos > 0
fieldput( nFieldPos, aRecValues[ 1 ][ nCounter ] )
endif
next
Return( Nil )
Re: Copy or paste one record
Thanks a lot for all your help, guys.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Copy or paste one record
An easy way:
Assume we want to copy Record at No 100 and paste over Record No. 200
Assume we want to copy Record No: 150 and append the same data as a new record.
Assume we want to copy Record at No 100 and paste over Record No. 200
Code: Select all
USE CUSTOMER
DATABASE oDbf
oDbf:GoTo( 100 )
CUSTOMER->( DBGOTO( 200 ) )
oDbf:Save()
Code: Select all
USE CUSTOMER
DATABASE oDbf
oDbf:GoTo( 150 )
CUSTOMER->( DBAPPEND() )
oDbf:Save()
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Copy or paste one record
Dear Mr. Rao,
thank you for this example.
Would you be so kind to explain what exactly this lines are doing:
DATABASE oDbf
CUSTOMER->( DBGOTO( 200 ) )
Why don’t we use here
oDbf:DBGoto(200)
oDbf:Save()
Thanks in advance
Otto
thank you for this example.
Would you be so kind to explain what exactly this lines are doing:
DATABASE oDbf
CUSTOMER->( DBGOTO( 200 ) )
Why don’t we use here
oDbf:DBGoto(200)
oDbf:Save()
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Copy or paste one record
CUSTOMER->( DBGOTO( 200 ) )
This is to prevent the buffer from being reloaded.
Another way you could do it:
oDBF:lBuffer:=.f.
oDBF:goto(200)
oDBF:save()
James
This is to prevent the buffer from being reloaded.
Another way you could do it:
oDBF:lBuffer:=.f.
oDBF:goto(200)
oDBF:save()
James
Re: Copy or paste one record
Maybe do You want to < RESET or REPLACE > defined vars of the new record ?
A test, using different copy-options for the destination record of types < numeric, logic and date > :
I added a new logic-field in DBF customer, to show how to receive different results.
Added many new options :
1. new copy-field-replacement
2. fieldprotection to replace fields with a new value
3. incremental seek
4. filter 2 - 6 can be a multiple selection fieldtyle N, L and D
The 2. record-copy shows the result of a protected field ( salary 11 ).
All other fields are replaced.
A 0 of the destination get APPENDS arecord
A >0 defines the destination record and replaces the values.
best regards
Uwe
A test, using different copy-options for the destination record of types < numeric, logic and date > :
I added a new logic-field in DBF customer, to show how to receive different results.
Added many new options :
1. new copy-field-replacement
2. fieldprotection to replace fields with a new value
3. incremental seek
4. filter 2 - 6 can be a multiple selection fieldtyle N, L and D
The 2. record-copy shows the result of a protected field ( salary 11 ).
All other fields are replaced.
A 0 of the destination get APPENDS arecord
A >0 defines the destination record and replaces the values.
best 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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: Copy or paste one record
For the final solution of the COPY-test, I added many options
In case something is still not working or possible to make it better, just give me a answer
Download :
http://www.pflegeplus.com/DOWNLOADS/Reccopy1.zip
Usage :
1. select any field-options for the record-copy
--- ( nothing selected will make a NORMAL copy without replacing something )
2. You can change from index to natural order
3. click on a record, to copy
---The record-number will be displayed in the start-get
4. use checkboxes to enable multiple filters
5. added incremental seek
6. possible to delete double names ( records ) after tests
7. possible to define multiple copys
8. exclude fields from replacing values with defined field-numbers
9. Fieldnumbers added to the xbrowse-header
10. Added a INI, to start with the last selected record
11. You can change the Dlg-background using the included function :
--- color = WD_BACKGRD( oDlg2, 1)
--- gradient = WD_BACKGRD( oDlg2, 2, nDColorF, nDColorB, nDGradPos, lDDirect)
--- brush = WD_BACKGRD( oDlg2, 3, , , , , cDBrush )
12. added a new field < Freelancer > to customer.dbf to handle the filter of logical fields
Destination-get = 0 will append a new record.
Destination-get > 0 will replace a record.
A selected replace-checkbox will auto-switch from .T. to .F. if nesessary,
to avoid double selections.
sample :
date-vars selected : < empty date >
date vars changed to DATE() will reset the checkbox < empty date > selected before to .F.
sample :
2 copies defined and replaced with empty date-fields ( 502, 503 )
2 rows before, 2 normal copys ( 500, 501 )
best regards
Uwe
In case something is still not working or possible to make it better, just give me a answer
Download :
http://www.pflegeplus.com/DOWNLOADS/Reccopy1.zip
Usage :
1. select any field-options for the record-copy
--- ( nothing selected will make a NORMAL copy without replacing something )
2. You can change from index to natural order
3. click on a record, to copy
---The record-number will be displayed in the start-get
4. use checkboxes to enable multiple filters
5. added incremental seek
6. possible to delete double names ( records ) after tests
7. possible to define multiple copys
8. exclude fields from replacing values with defined field-numbers
9. Fieldnumbers added to the xbrowse-header
10. Added a INI, to start with the last selected record
11. You can change the Dlg-background using the included function :
--- color = WD_BACKGRD( oDlg2, 1)
--- gradient = WD_BACKGRD( oDlg2, 2, nDColorF, nDColorB, nDGradPos, lDDirect)
--- brush = WD_BACKGRD( oDlg2, 3, , , , , cDBrush )
12. added a new field < Freelancer > to customer.dbf to handle the filter of logical fields
Destination-get = 0 will append a new record.
Destination-get > 0 will replace a record.
A selected replace-checkbox will auto-switch from .T. to .F. if nesessary,
to avoid double selections.
sample :
date-vars selected : < empty date >
date vars changed to DATE() will reset the checkbox < empty date > selected before to .F.
sample :
2 copies defined and replaced with empty date-fields ( 502, 503 )
2 rows before, 2 normal copys ( 500, 501 )
best 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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Copy or paste one record
I forgot another simpler way:
The function takes care of locking and unlocking automatically.
We can also copy selected fields
Code: Select all
DBGOTO( 100 )
h := FW_RecToHash()
DBGOTO( 200)
FW_HashToRec( h )
We can also copy selected fields
Code: Select all
DBGOTO( 100 )
h := FW_RecToHash( "FIRST,CITY,SALARY" )
DBGOTO( 200 )
FW_HashToRec( h )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India