Copy and DeepCopy (Recordset functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span>
{{Template:Recordset:Copy and DeepCopy subtitle}}
[[Category:Recordset methods|Copy and DeepCopy functions]]
<p>
<var>Copy</var> and <var>DeepCopy</var> are members of the <var>[[Recordset class|Recordset]]</var> class.
</p>


<var>Copy</var> is a function that makes a copy of a <var>Recordset</var> object.
<var>Copy</var> is a function that makes a copy of a <var>Recordset</var> object.
<var>DeepCopy</var> is a version 6.8 function that performs the identical function
<var>DeepCopy</var> performs the identical function
as <var>Copy</var>, but flags the <var>Recordset</var> class as "deep-copyable"
as <var>Copy</var>, but it flags the <var>Recordset</var> class as "deep-copyable"
(as described in [[Copying objects#The Object class copy methods|"The Object class copy methods"]]).
(as described in [[Copying objects#The Object class copy methods|"The Object class copy methods"]]).
==Syntax==
==Syntax==
<p class="syntax">%newSet = %recSet:Copy( [lockstrength]        -
{{Template:Recordset:Copy syntax}}
                      [,&nbsp;LoopLockStrength=lockstrength] )
{{Template:Recordset:DeepCopy syntax}}


%newSet = %recSet:DeepCopy([lockstrength]    -
                        [,&nbsp;LoopLockStrength=lockstrength] )
</p>
===Syntax Terms===
===Syntax Terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%newSet</th>
<tr><th>%outRecordset</th>
<td>A <var>Recordset</var> object created by this method that contains a copy of the method object.
<td>A <var>Recordset</var> object created by this method that contains a copy of the method object.
</td></tr>
</td></tr>
<tr><th>%recSet</th>
 
<tr><th>recordset</th>
<td>A <var>Recordset</var> object variable. The variable can be null, in which case the output object will also be null.
<td>A <var>Recordset</var> object variable. The variable can be null, in which case the output object will also be null.
</td></tr>
</td></tr>
<tr><th>lockstrength</th>
<tr><th>lockstrength</th>
<td>A value of the <var>LockStrength</var> enumeration that is the lock strength to give to the instantiated <var>Recordset</var> object. Options are: <var>None</var>, <var>Share</var>, or <var>Exclusive</var>, as described in [[New (Recordset constructor)|"New (Recordset constructor)"]]. This is an optional parameter, and it defaults to the lock strength of the method object. Specifying a stronger <var>LockStrength</var> than the method object's lock strength is invalid and results in request cancellation.
<td>A value of the <var>LockStrength</var> enumeration that is the lock strength to give to the instantiated <var>Recordset</var> object. Options are: <var>None</var>, <var>Share</var>, or <var>Exclusive</var>, as described in [[New (Recordset constructor)|"New (Recordset constructor)"]].  
</td></tr>
<p>
<tr><th><b>LoopLockStrength=</b>lockstrength</th>
This is an optional parameter, and it defaults to the lock strength of the method object. </p>
<td>The lock strength to be used for loops on the copied <var>Recordset</var>. This is an optional, name required, parameter, and it defaults to the <var>LoopLockStrength</var> of the method object <var>Recordset</var>. This parameter is only available in <var class="product">Sirius Mods</var> 7.0 and later. See [[Recordset class#LoopLockStrength for Recordsets|"LoopLockStrength for Recordsets"]].
<p>
Specifying a stronger <var>LockStrength</var> than the method object's lock strength is invalid and results in request cancellation.</p></td></tr>


<tr><th><var>LoopLockStrength</var></th>
<td>The lock strength to be used for loops on the copied <var>Recordset</var>. This is an optional, [[Notation conventions for methods#Named parameters|name required]], parameter, and it defaults to the <var>LoopLockStrength</var> of the method object <var>Recordset</var> (see [[Recordset class#LoopLockStrength for Recordsets|"LoopLockStrength for Recordsets"]]).
</td></tr></table>
</td></tr></table>
==Usage Notes==
==Usage Notes==
<ul>
<ul>
Line 37: Line 37:
that the user does not already hold.
that the user does not already hold.
Therefore, <var>Copy</var> cannot produce a record locking conflict.
Therefore, <var>Copy</var> cannot produce a record locking conflict.
<li>Specifying a lock strength greater than the lock strength of the method
<li>Specifying a lock strength greater than the lock strength of the method
object is a request-cancelling error.
object is a request-cancelling error.
</ul>
</ul>
==Example==
==Example==
In the following example, a base record set is created, copied, then added to:
In the following example, a base record set is created, copied, then added to:
<p class="code"> begin
<p class="code">begin
  %baseStooges is object recordset in file glwproc
  %baseStooges is object recordset in file glwproc
  %copyStooges is object recordset in file glwproc
  %copyStooges is object recordset in file glwproc
  %curleyStooge is object recordset in file glwproc
  %curleyStooge is object recordset in file glwproc


  fd to %baseStooges name = 'MOE' or name = 'LARRY'
  fd to %baseStooges name = 'MOE' or name = 'LARRY'
      end find
    end find
  text
  text noCont
      ------
    ------
      The names of the %baseStooges are:
    The names of the %baseStooges are:
  end text
  end text
  fr in %baseStooges
  fr in %baseStooges
      text
    text
        {name}
        {name}
      end text
    end text
  end for
  end for


  %copyStooges = %baseStooges:copy
  %copyStooges = %baseStooges:copy
  fd to %curleyStooge with name = 'CURLEY'
  fd to %curleyStooge with name = 'CURLEY'
      end find
    end find
  %copyStooges:addRecordset( %curleyStooge )
  %copyStooges:addRecordset( %curleyStooge )
  text
  text noCont
      ------
    ------
      The names of the {%copyStooges:Count} %copyStooges are:
    The names of the {%copyStooges:Count} %copyStooges are:
  end text
  end text
  fr in %copyStooges
  fr in %copyStooges
      text
    text
        {name}
        {name}
      end text
    end text
  end for
  end for
end
end
</p>
</p>


The example results follow:
The example results follow:
<p class="output"> ------
<p class="output">------
The names of the %baseStooges are:
The names of the %baseStooges are:
MOE
MOE
LARRY
LARRY
------
------
The names of the 3 %copyStooges are:
The names of the 3 %copyStooges are:
MOE
MOE
LARRY
LARRY
CURLEY
CURLEY
</p>
</p>
{{Template:Recordset:Copy and DeepCopy footer}}

Latest revision as of 15:31, 11 November 2012

Copy or deep copy this Recordset object (Recordset class)


Copy is a function that makes a copy of a Recordset object. DeepCopy performs the identical function as Copy, but it flags the Recordset class as "deep-copyable" (as described in "The Object class copy methods").

Syntax

%outRecordset = recordset:Copy[( [lockStrength], - [LoopLockStrength= lockStrength])]

%outRecordset = recordset:DeepCopy[( [lockStrength], - [LoopLockStrength= lockStrength])]

Syntax Terms

%outRecordset A Recordset object created by this method that contains a copy of the method object.
recordset A Recordset object variable. The variable can be null, in which case the output object will also be null.
lockstrength A value of the LockStrength enumeration that is the lock strength to give to the instantiated Recordset object. Options are: None, Share, or Exclusive, as described in "New (Recordset constructor)".

This is an optional parameter, and it defaults to the lock strength of the method object.

Specifying a stronger LockStrength than the method object's lock strength is invalid and results in request cancellation.

LoopLockStrength The lock strength to be used for loops on the copied Recordset. This is an optional, name required, parameter, and it defaults to the LoopLockStrength of the method object Recordset (see "LoopLockStrength for Recordsets").

Usage Notes

  • You can only create a copy of lock strength less than or equal to the original, so Copy needs to acquire no locks that the user does not already hold. Therefore, Copy cannot produce a record locking conflict.
  • Specifying a lock strength greater than the lock strength of the method object is a request-cancelling error.

Example

In the following example, a base record set is created, copied, then added to:

begin %baseStooges is object recordset in file glwproc %copyStooges is object recordset in file glwproc %curleyStooge is object recordset in file glwproc fd to %baseStooges name = 'MOE' or name = 'LARRY' end find text noCont ------ The names of the %baseStooges are: end text fr in %baseStooges text {name} end text end for %copyStooges = %baseStooges:copy fd to %curleyStooge with name = 'CURLEY' end find %copyStooges:addRecordset( %curleyStooge ) text noCont ------ The names of the {%copyStooges:Count} %copyStooges are: end text fr in %copyStooges text {name} end text end for end

The example results follow:

------ The names of the %baseStooges are: MOE LARRY


The names of the 3 %copyStooges are: MOE LARRY CURLEY