table.DUPLICATE Function

Syntax

V Duplicate(C tablename[,N flags])

Arguments

tablename

The resulting table's path, filename and extension (.dbf).

flags

Optional. Default = 0. The Flags parameter allows you to control the options to the duplication.

Flag
Details
0

Records: No, Layouts/ Operations: No, Field Rules: No, Indexes: No

1

Records: No, Layouts/ Operations: No, Field Rules: No, Indexes: Yes

2

Records: No, Layouts/ Operations: Yes, Field Rules: Yes, Indexes: No

3

Records: No, Layouts/ Operations: Yes, Field Rules: Yes, Indexes: Yes

4

Records: Yes, Layouts/ Operations: No, Field Rules: No, Indexes: No

5

Records: Yes, Layouts/ Operations: No, Field Rules: No, Indexes: Yes

6

Records: Yes, Layouts/ Operations: Yes, Field Rules: Yes, Indexes: No

7

Records: Yes, Layouts/ Operations: Yes, Field Rules: Yes, Indexes: Yes

8

Records: No, Layouts/ Operations: No, Field Rules: Yes, Indexes: No

9

Records: No, Layouts/ Operations: No, Field Rules: Yes, Indexes: Yes

12

Records: Yes, Layouts/ Operations: No, Field Rules: Yes, Indexes: No

13

Records: Yes, Layouts/ Operations: No, Field Rules: Yes, Indexes: Yes

Description

Create a copy of the table, with all records and layouts.

Discussion

The <TBL>.DUPLICATE() method makes a duplicate copy of the table. You must specify the resulting table's path, filename and extension (.dbf) in the Filename parameter. Note : If you select a flag of 0, the dictionary is not copied. However, any fields in the source <TBL> that are defined as auto-increment in field rules are kept as auto-increment fields in Filename. If you want to copy all of the fields and all of the records in a table to a new table, the <TBL>.DUPLICATE() method is appropriate. However, if you want to select which fields and records to copy, use the <TBL>.COPY() method.

Example 

This script duplicates the structure of the current table (but does not copy the dictionary, records or indexes) then copies the current record to the new table.

dim tbl as P
tbl_source = table.current()
'Use the 0 paremeter to copy structure only
tbl_source.duplicate("c:\A5\new.dbf",0)
'Open the new table
tbl_new = table.open("c:\A5\new.dbf")
'Put new table into enter mode
tbl_new.enter_begin()
'Clone the record from the current table
tbl_new.record_clone(tbl_source)
tbl_new.enter_end(.T.)
tbl_new.close()

See Also