Copy (Record function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Record:Copy subtitle}}
#REDIRECT [[Copy and DeepCopy (Record functions)]]
 
<var>Copy</var> is a function that makes an exact copy of a <var>Record</var> object.
It is identical to the <var>Record</var> <var>[[DeepCopy (Record function)|DeepCopy]]</var> method. <var>Record</var> objects are always copyable and "deep-copyable" (as these terms are described in [[Copying objects#The Object class copy methods|"The Object class copy methods"]]).
 
==Syntax==
<p class="syntax">%newRec = %rec:Copy( [lockstrength]        -
                  [,&nbsp;LoopLockStrength=lockstrength] )
 
</p>
===Syntax Terms===
<table class="syntaxTable">
<tr><th>%newRec</th>
<td>A <var>Record</var> object created by this method that contains a copy of the method object.
</td></tr>
<tr><th>%rec</th>
<td>A <var>Record</var> object variable. The variable can be null, in which case the output object will also be null.
</td></tr>
<tr><th>lockstrength</th>
<td>A value of the <var>LockStrength</var> enumeration that is the lock strength to give to the instantiated <var>Record</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. This parameter is only available in <var class="product">Sirius Mods</var> 7.0 and later.
</td></tr>
<tr><th><var>LoopLockStrength</var></th>
<td>The lock strength to be used for loops on the copied <var>Record</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>Record</var>. See [[Record class#LoopLockStrength for Records|"LoopLockStrength for Records"]]. This parameter is available in <var class="product">Sirius Mods</var> 7.0 and later.
 
</td></tr></table>
==Usage Notes==
<ul>
<li>Before <var class="product">Sirius Mods</var> 7.0,
<var>Copy</var> did not allow setting of the target lock strength.
So, before <var class="product">Sirius Mods</var> 7.0,
to make a <var>Record</var> object copy with a different lock strength, the <var>New</var> or
<var>CurrentRecord</var> (inside a <var>For</var> record loop) methods had to be used.
<li>Since a <var>Record</var> object and its copy reference the same underlying
record, there generally isn't a good reason to make a copy of a <var>Record</var>
object &mdash; it makes more sense to just assign the reference to the
<var>Record</var> object.
The copy functionality for <var>Records</var> is mainly for the support of <var>DeepCopy</var>
of <var>Record</var> objects to facilitate passing of these objects to and
from [[Daemon class|daemons]].
<li>The following example illustrates the use of the <var>Copy</var> function:
<p class="code"> %firstRec      is object record in file geeks
%currentRec    is object record in file geeks
  ...
%currentRec = %firstRec:copy
</p>
</ul>
==See also==
{{Template:Record:Copy footer}}
[[Category:Record methods|Copy function]]

Latest revision as of 01:02, 8 November 2012