New (Record constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Created page with "<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span> <p> <var>New</var> is a member of the <var>Record</var> class. </p> This sha...")
 
mNo edit summary
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span>
{{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.


<p>
==Syntax==
<var>New</var> is a member of the <var>[[Record class|Record]]</var> class.
{{Template:Record:file:New syntax}}
</p>
{{Template:Record:group:New syntax}}
 
===Syntax terms===
<table class="syntaxTable">
<tr><th>%fileRecord</th>
<td>A <var>Record</var> object variable declared in file context.</td></tr>
 
<tr><th>%groupRecord</th>
<td>A <var>Record</var> object variable declared in group context.</td></tr>


This shared function instantiates a <var>Record</var> object.
<tr><th nowrap="true"><var>[%(Record In <i>filOrGrp name</i>)]</var></th>
It has one required parameter if in file context, two required parameters
<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>
if in group context, and one optional parameter in either context.


The parameters are applied by the <var>New</var> constructor to the newly instantiated object.
<tr><th>number</th>
==Syntax==
<td>The number of the record to which the instantiated <var>Record</var> object will refer.</td></tr>
<p class="syntax">%filerec = [%filerec:] New( recnum, [lockstr]    -
                      [,&nbsp;LoopLockStrength=lockstrength] )


%grouprec = [%grouprec:] New( recnum, filename, [lockstr]  -
<tr><th>string</th>
                        [,&nbsp;LoopLockStrength=lockstrength] )
</p>
===Syntax Terms===
<table class="syntaxTable">
<tr><th>%filerec</th>
<td>A declared <var>Record</var> object variable in file context.
</td></tr>
<tr><th>%grouprec</th>
<td>A declared <var>Record</var> object variable in group context.
</td></tr>
<tr><th>recnum</th>
<td>The number of the record to which the instantiated <var>Record</var> object will refer.
</td></tr>
<tr><th>filename</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>lockstr</th>
<td>The value of a Lockstrength 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></tr>
<tr><th><b>LoopLockStrength=</b>lockstrength</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></tr></table>
<tr><th>lockstrength</th>
==Usage Notes==
<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>.
 
This is an optional parameter, and it defaults to <var>Share</var>.</td></tr>
 
<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></tr>
</table>
 
==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>
<li>The <var>[[LockStrength (Record property)|LockStrength]]</var> returns the locking
'''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
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>
[[Category:Record methods|New constructor]]
 
==See also==
{{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