CopyRef Method for LCFieldlist

This method creates a new fieldlist object instance as a partial copy of another fieldlist. The fields in the original fieldlist are not copied, but are referenced.

This method creates a new fieldlist with separate name space but with the same fields and data space as an existing fieldlist. The field names are copied, but the new fieldlist references the original fields. In this situation, any changes to the data of one fieldlist is actually a change to the data for all fieldlists referencing the same data space.

Note: The name of a field is not stored in the LCField object. This information is stored in the LCFieldlist. Therefore, if you use CopyRef and then rename a field (SetName method), the same field will be known by different names in the two lists.

To copy a fieldlist's metadata and data, use LCFieldlistCopy.

Defined In

LCFieldlist

Syntax

Set fldListRecordNew = fldListRecord. CopyRef

Parameters

Parameter

Description

fldListRecord

LCFieldlist. The fieldlist that you want to make a reference copy of.

Return Values

Value

Description

fldListRecordNew

LCFieldlist. The reference copy of the fieldlist.

Example

Option Public
Uselsx "*lsxlc" 
Sub Initialize
  Dim olist As New LCFieldlist
  Dim nlist As LCFieldlist
  Dim ofield As LCField
  Set ofield = olist.Append ("FirstName", LCTYPE_TEXT)
  ofield.Text = "Chi Len"
  Set nlist = olist.CopyRef
  Set nfield = nlist.GetField (1)
  Call olist.SetName (1, "FullName")
  ofield.Text = "Cheiko"
  Print "The copy contains field named " & nlist.Names(0) &  ", value is " & nfield.Text(0)
  Print "The original contains field named " & olist.Names(0) &  ", value is " & ofield.Text(0)
End Sub

Example Output

The copy contains field named FirstName, value is Cheiko
The original contains field named FullName, value is Cheiko