CurrentRecord (Record function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (minor formatting)
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Record:CurrentRecord subtitle}}
{{Template:Record:CurrentRecord subtitle}}


This shared function instantiates a <var>Record</var> object
<var>CurrentRecord</var> is a [[Notation conventions for methods#Shared methods and constructors|shared function]] that acts as a constructor.
from the current record in a <var>For</var> loop or record set.
 
 
==Syntax==
==Syntax==
{{Template:Record:CurrentRecord syntax}}
{{Template:Record:CurrentRecord syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%(Record)</th>
<tr><th>%record</th>
<td>Since this is a shared method, this method object can be the class name, <var>Record</var>, in parentheses, or it can be a declared <var>Record</var> object variable, which must have the same file or group context as the <var>For</var> loop within which <var>CurrentRecord</var> is invoked.
<td>A <var>Record</var> object variable to contain the instantiated object instance. This variable must be declared with the appropriate file or group context. See [[#Usage notes|Usage notes]], below.</td></tr>
Under <var class="product">Sirius Mods</var> version 6.8 and later, the <var>CurrentRecord</var> method does not have to be preceded by any method object, since it acts like a constructor.
 
For more information about shared methods, see [["Shared class members"]].
<tr><th nowrap="true"><var>[%(Record In </var>filOrGrp name<var>):]</var></th>
</td></tr>
<td>This optional specification of the class in parentheses denotes a [[Notation conventions for methods#Constructors|virtual constructor]]. See [[#Usage notes|Usage notes]], below, for more information about invoking a <var>Record</var> virtual constructor. </td></tr>
 
<tr><th>lockstr</th>
<tr><th>lockstr</th>
<td>The value of a <var>Lockstrength</var> enumeration: <var>None</var>, <var>Share</var>, or <var>Exclusive</var>. These correspond to standard <var class="product">Model 204</var> record-locking levels, as described below. The default lock strength of the new <var>Record</var> object is <var>Share</var>. <dl> <dt>None <dd>Record is not locked. <br> No locks are held on the object, so there is no conflict with others holding <var>Share</var> or <var>Exclusive</var> locks (readers and updaters may proceed). <dt>Share <dd>Record is share locked. <br> This level allows other users to hold a <var>Share</var> lock, but not an <var>Exclusive</var> lock (allows readers but not updaters to proceed). <dt>Exclusive <dd>Record is exclusively locked. <br> This level prohibits others from holding either an <var>Exclusive</var> lock or a <var>Share</var> lock. It is generally used for update. </dl>
<td>The value of a <var>Lockstrength</var> enumeration: <var>None</var>, <var>Share</var>, or <var>Exclusive</var>. These correspond to standard <var class="product">Model 204</var> record-locking levels, as described below. The default lock strength of the new <var>Record</var> object is <var>Share</var>. <dl>  
</td></tr>
<dt>None <dd>Record is not locked. <br> No locks are held on the object, so there is no conflict with others holding <var>Share</var> or <var>Exclusive</var> locks (readers and updaters may proceed).  
<tr><th><var>LoopLockStrength=lockstrength</var></th>
<dt>Share <dd>Record is share locked. <br> This level allows other users to hold a <var>Share</var> lock, but not an <var>Exclusive</var> lock (allows readers but not updaters to proceed). <dt>Exclusive <dd>Record is exclusively locked. <br> This level prohibits others from holding either an <var>Exclusive</var> lock or a <var>Share</var> lock. It is generally used for update.  
<td>The lock strength to be used for loops on the <var>Record</var>. This is an optional, name required, parameter, and it defaults to <var>None</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.
</dl></td></tr>
 
<tr><th><var>LoopLockStrength</var></th>
<td>The lock strength to be used for loops on the <var>Record</var>. This is an optional, [[Notation conventions for methods#Named parameters|name required]], parameter, and it defaults to <var>None</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>


</td></tr></table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>CurrentRecord</var> must be invoked from inside a record loop
<li>As described in [[Record class#Using CurrentRecord to instantiate a Record object|Using CurrentRecord to instantiate a Record object]], <var>CurrentRecord</var> must be invoked from a record context
that has the same file or group context as declared for the <var>Record</var>
that has the same file or group context as declared for the <var>Record</var>
object variable.
object variable. </li>
<li>Under <var class="product">Sirius Mods</var> version 6.8 and later, the <var>CurrentRecord</var> method name
 
does not have to be preceded by the class name or by an object variable.
<li>As described in [[Object variables#Virtual Constructor methods|Virtual Constructor methods]], <var>CurrentRecord</var> can be invoked with
<li>For more information and examples, see
no method object, with an explicit class specification, or with a <var>Record</var> object variable,
[[Record class#Using CurrentRecord to instantiate a Record object|"Using CurrentRecord to instantiate a Record object]].
even if that object is <var>Null</var>:
<p class="code">%rec = CurrentRecord
 
%rec = %(Record in file Myfile):CurrentRecord
 
%rec = %rec:CurrentRecord
</p>
<p class="note">'''Note:'''
As shown in the second of these above, if you explicitly specify the
class name, you must include the file or group context, which must be the same as that declared for <code>%rec</code>. </p></li>
</ul>
</ul>
==See also==
==See also==
{{Template:Record:CurrentRecord footer}}
{{Template:Record:CurrentRecord footer}}

Latest revision as of 19:03, 18 August 2015

Create a Record object from current record in For loop or Recordset (Record class)


CurrentRecord is a shared function that acts as a constructor.


Syntax

%record = [%(Record In filOrGrp name):]CurrentRecord[( [lockStrength], - [LoopLockStrength= lockStrength])] Throws RecordLockingConflict

Syntax terms

%record A Record object variable to contain the instantiated object instance. This variable must be declared with the appropriate file or group context. See Usage notes, below.
[%(Record In filOrGrp name):] This optional specification of the class in parentheses denotes a virtual constructor. See Usage notes, below, for more information about invoking a Record virtual constructor.
lockstr The value of a Lockstrength enumeration: None, Share, or Exclusive. These correspond to standard Model 204 record-locking levels, as described below. The default lock strength of the new Record object is Share.
None
Record is not locked.
No locks are held on the object, so there is no conflict with others holding Share or Exclusive locks (readers and updaters may proceed).
Share
Record is share locked.
This level allows other users to hold a Share lock, but not an Exclusive lock (allows readers but not updaters to proceed).
Exclusive
Record is exclusively locked.
This level prohibits others from holding either an Exclusive lock or a Share lock. It is generally used for update.
LoopLockStrength The lock strength to be used for loops on the Record. This is an optional, name required, parameter, and it defaults to None. See LoopLockStrength for Records. This parameter is available in Sirius Mods 7.0 and later.

Usage notes

  • As described in Using CurrentRecord to instantiate a Record object, CurrentRecord must be invoked from a record context that has the same file or group context as declared for the Record object variable.
  • As described in Virtual Constructor methods, CurrentRecord can be invoked with no method object, with an explicit class specification, or with a Record object variable, even if that object is Null:

    %rec = CurrentRecord %rec = %(Record in file Myfile):CurrentRecord %rec = %rec:CurrentRecord

    Note: As shown in the second of these above, if you explicitly specify the class name, you must include the file or group context, which must be the same as that declared for %rec.

See also