New (Record constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Record:New subtitle}}
{{Template:Record:New subtitle}}
This method has one required parameter if in file context, two required parameters if in group context, and two optional parameters in either context. The parameters are applied by the <var>New</var> constructor to the newly instantiated object.


This shared function instantiates a <var>Record</var> object that refers to a record in a group. To create a Record object that refers to a record in file context, use the same-named [[New (Record constructor)|New]] method, which has only one
required parameter in addition to two optional parameters.
The parameters are applied by the <var>New</var> constructor to the newly instantiated object.
==Syntax==
==Syntax==
{{Template:Record:file:New syntax}}
{{Template:Record:file:New syntax}}
{{Template:Record:group:New syntax}}
{{Template:Record:group:New syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%fileRecord</th>
<td>A <var>Record</var> object variable declared in file context.</td></tr>
<tr><th>%groupRecord</th>
<tr><th>%groupRecord</th>
<td>A declared <var>Record</var> object variable in group context.
<td>A <var>Record</var> object variable declared in group context.</td></tr>
</td></tr>
 
<tr><th nowrap="true"><var>[%(Record In <i>filOrGrp name</i>)]</var></th>
<td>The optional class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>Record</var> <var>Constructor</var>.</td></tr>
 
<tr><th>number</th>
<tr><th>number</th>
<td>The number of the record to which the instantiated <var>Record</var> object will refer.
<td>The number of the record to which the instantiated <var>Record</var> object will refer.</td></tr>
</td></tr>
 
<tr><th>string</th>
<tr><th>string</th>
<td>For group context, the name of the file that contains the record that the instantiated <var>Record</var> object will reference.
<td>For group context, the name of the file that contains the record that the instantiated <var>Record</var> object will reference.
</td></tr>
</td></tr>
<tr><th>lockstrength</th>
<tr><th>lockstrength</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 record object is <var>Share</var>, matching the locking behavior of a <var class="product">User Language</var> <var>For Record Number</var> statement. <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 strength of the lock to be used for the record referenced by the object. This value is a <var>[[LockStrength_enumeration|LockStrength enumeration]]</var> value: <var>None</var>, <var>Share</var>, or <var>Exclusive</var>.
</td></tr>
 
This is an optional parameter, and it defaults to <var>Share</var>.</td></tr>
 
<tr><th><var>LoopLockStrength</var></th>
<tr><th><var>LoopLockStrength</var></th>
<td>The lock strength to be used for <var>For Record</var> loops on the <var>Record</var> object. 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 under <var class="product">Sirius Mods</var> 7.0 and later.
<td>The lock strength to be used for <var>For Record</var> loops on the <var>Record</var> object. 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 under <var class="product">Sirius Mods</var> 7.0 and later.</td></tr>
 
</table>
</td></tr></table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>New</var> is a constructor and as such can be called with no object, with an
<li>As described in [[Object variables#Using New or other Constructors|"Using New or other Constructors"]], <var>New</var> can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is <var>Null</var>:
explicit class name, or with an object variable, even if that object is null:
<p class="code">%rec = new(share)
<p class="code"> %rec = new(share)
 
%rec = %(Record):new(exclusive)
%rec = %(Record in file sirLocal):new(exclusive)
%rec = %rec:new(none)
 
%rec = %rec:new(none)
</p>
</p>
'''Note:'''
As shown above, when explicitly indicating the
class, both the class name and the file or group context must be
specified just as they are on the <var>Record</var> variable's declaration.
<li>The <var>[[LockStrength (Record function)|LockStrength]]</var> returns the locking
<li>The <var>[[LockStrength (Record function)|LockStrength]]</var> returns the locking
level of a <var>Record</var> object.
level of a <var>Record</var> object.
<li>For more information about constructors,
<li><var>New</var> is not the only way to instantiate a <var>Record</var> object. See
see [[Object variables#Creating object instances|"Creating object instances"]]
[[Record class#Instantiating Record objects|"Instantiating Record objects"]].
<li>For more information about using <var>New</var>, see
[[Record class#Using New to instantiate a Record object|"Using New to instantiate a Record object"]].
</ul>
</ul>
==See also==
==See also==
{{Template:Record:New footer}}
{{Template:Record:New footer}}

Latest revision as of 01:36, 8 November 2012

Create a new Record object (Record class)

This method has one required parameter if in file context, two required parameters if in group context, and two optional parameters in either context. The parameters are applied by the New constructor to the newly instantiated object.

Syntax

%fileRecord = [%(Record In filOrGrp name):]New( number, [lockStrength], - [LoopLockStrength= lockStrength]) Throws RecordLockingConflict

%groupRecord = [%(Record In filOrGrp name):]New( number, string, - [lockStrength], - [LoopLockStrength= lockStrength]) Throws RecordLockingConflict

Syntax terms

%fileRecord A Record object variable declared in file context.
%groupRecord A Record object variable declared in group context.
[%(Record In filOrGrp name)] The optional class name in parentheses denotes a Constructor. See "Usage notes", below, for more information about invoking a Record Constructor.
number The number of the record to which the instantiated Record object will refer.
string For group context, the name of the file that contains the record that the instantiated Record object will reference.
lockstrength The strength of the lock to be used for the record referenced by the object. This value is a LockStrength enumeration value: None, Share, or Exclusive. This is an optional parameter, and it defaults to Share.
LoopLockStrength The lock strength to be used for For Record loops on the Record object. This is an optional, name required, parameter, and it defaults to None. See "LoopLockStrength for Records". This parameter is available under Sirius Mods 7.0 and later.

Usage notes

  • As described in "Using New or other Constructors", New can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is Null:

    %rec = new(share) %rec = %(Record in file sirLocal):new(exclusive) %rec = %rec:new(none)

    Note: As shown above, when explicitly indicating the class, both the class name and the file or group context must be specified just as they are on the Record variable's declaration.

  • The LockStrength returns the locking level of a Record object.
  • New is not the only way to instantiate a Record object. See "Instantiating Record objects".

See also