table.CREATE_CLONE Function
Syntax
Arguments
- filename
The name of the new table.
- flags
Optional. Determines the access privileges that apply to the new table file. It uses the following system variables:
- Variable
- Function
- FILE_RO_EXCLUSIVE
Read Only (Exclusive)
- FILE_RW_EXCLUSIVE
Read or Write (Exclusive)
- FILE_RO_SHARED
Read Only (Shared)
- FILE_RW_SHARED
Read or Write (Shared)
Description
Create an empty copy of the table.
Discussion
The <TBL>.CREATE_CLONE() method creates a new empty table that matches the structure of an existing table. The <TBL>.CREATE_CLONE() method is useful for creating a new table in which records are to be added. It can also be used with the <TBL>.RECORD_CLONE() method to copy records from one table to another. <TBL> is the pointer to the existing table that you want to clone. Filename is the name of the new table. <TABLE_2> is the pointer to the new table created by this method. This table is a clone of <TBL>. Note : The <TBL>.CREATE_CLONE() method will not copy the source table's field rules or its records. To copy field rules and/or copy records, use the <TBL>.COPY() or <TBL>.DUPLICATE() methods.
Example
This script copies the structure of the current table to a new table, and then copies all the currently selected records in the current table.
dim tbl_target as P dim tbl_source as P dim filename as C tbl_source = table.current() filename = ui_get_file("Copy To:", "Tables (*.DBF)", "", "N") if filename = "" then end end if tbl_target = tbl_source.create_clone(filename) tbl_source.fetch_first() while .NOT. tbl_source.fetch_EOF() tbl_target.enter_begin() tbl_target.record_clone(tbl_source) tbl_target.enter_end(.T.) tbl_source.fetch_next() end while tbl_target.close()
See Also