New (RecordsetCursor 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> New constructor <p> <var>New</var> is a member of the <var...")
 
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span>
{{Template:RecordsetCursor:New subtitle}}
[[Category:RecordsetCursor methods|New constructor]]
<p>
<var>New</var> is a member of the <var>[[RecordsetCursor class|RecordsetCursor]]</var> class.
</p>
 
This shared function instantiates a <var>RecordsetCursor</var> object.
This shared function instantiates a <var>RecordsetCursor</var> object.
The method requires a <var>Recordset</var> or <var>SortedRecordset</var> object parameter,
The method requires a <var>Recordset</var> or <var>SortedRecordset</var> object parameter,
and it may have a <var>LoopLockStrength</var>.
and it may have a <var>LoopLockStrength</var> parameter.


Available as of <var class="product">Sirius Mods</var> version 7.6, the <var>New</var> method is an alternative
Available as of <var class="product">Sirius Mods</var> version 7.6, the <var>New</var> method is an alternative
to using the (<var>Recordset</var> or <var>SortedRecordset</var>) <var>Cursor</var> constructor, as described
to using the (<var>Recordset</var> or <var>SortedRecordset</var>) <var>Cursor</var> constructor, as described
in [[RecordsetCursor#Declaration and instantiation|"Declaration and instantiation"]].
in [[RecordsetCursor class#Declaration and instantiation|"Declaration and instantiation"]].
==Syntax==
==Syntax==
<p class="syntax">%rscursor = [class:]New( %recset [,&nbsp;LoopLockStrength=ls] )
{{Template:RecordsetCursor:New syntax}}
</p>
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%rscursor</th>
<tr><th>%recordsetCursor</th>
<td>A declared <var>RecordsetCursor</var> object including its file/group context.
<td>A <var>RecordsetCursor</var> object.
</td></tr>
</td></tr>
<tr><th>class</th>
<tr><th nowrap="true"><var>[%(RecordsetCursor In </var>filOrGrp name<var>):]</var></th>
<td>Either a parenthesized class name, as in <code>%(RecordsetCursor in file bar</code>), or a non-parenthesized variable in the class, as in <code>%rscursor</code>.
<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>RecordsetCursor</var> <var>Constructor</var>.
</td></tr>
</td></tr>
<tr><th>%recset</th>
<tr><th>recordset</th>
<td>A required <var>Recordset</var> or <var>SortedRecordset</var> object.
<td>A required <var>Recordset</var> or <var>SortedRecordset</var> object.
</td></tr>
</td></tr>
<tr><th><var>LoopLockStrength</var></th>
<tr><th><var>LoopLockStrength</var></th>
<td>This optional, name required, parameter is a <var>LockStrength</var> enumeration setting the minimum lock strength for a record in a <var>For Record At</var> loop on a <var>RecordsetCursor</var> object. Options are <var>None</var> (default), <var>Share</var>, or <var>Exclusive</var>, further described in <var>[[CurrentRecord (RecordsetCursor function)|CurrentRecord]]</var>.
<td>This optional, name required, parameter is a <var>LockStrength</var> enumeration setting the minimum lock strength for a record in a <var>For Record At</var> loop on a <var>RecordsetCursor</var> object. Options are <var>None</var> (default), <var>Share</var>, or <var>Exclusive</var>, further described in <var>[[CurrentRecord (RecordsetCursor function)|CurrentRecord]]</var>.
For more information about loop lock strength, see [[RecordsetCursor#LoopLockStrength for RecordsetCursors|"LoopLockStrength for RecordsetCursors"]]. '''Note:''' This parameter is only valid if ''%recset'' is a <var>Recordset</var> object.
For more information about loop lock strength, see [[RecordsetCursor class#LoopLockStrength for RecordsetCursors|"LoopLockStrength for RecordsetCursors"]]. <br>'''Note:''' This parameter is only valid if <var class="term">recordset</var> is a <var>Recordset</var> object.


</td></tr></table>
</td></tr></table>
==Usage Notes==
 
==Usage notes==
<ul>
<ul>
<li>If ''%recset'' is empty, New returns a <var>RecordsetCursor</var>
<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>:
<p class="code">%rscursor = new
 
%rscursor = %(RecordsetCursor in group fleet):new
 
%rscursor = %rscursor:new
</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>RecordsetCursor</var> variable's declaration.
<li>If <var class="term">recordset</var> is empty, New returns a <var>RecordsetCursor</var>
object with the state <var>Empty</var>.
object with the state <var>Empty</var>.
This is different from the <var>Cursor</var> methods of instantiation,
This is different from the <var>Cursor</var> methods of instantiation,
Line 53: Line 59:
</p>
</p>


The <var>Cursor</var> method constructor cannot be used for this purpose.
The <var>[[Cursor (Recordset function)|Cursor]]</var> <var>Recordset</var> function cannot be used for this purpose.
</ul>
</ul>
==See also==
{{Template:RecordsetCursor:New footer}}

Latest revision as of 20:54, 12 November 2012

Create a new RecordsetCursor object (RecordsetCursor class)

This shared function instantiates a RecordsetCursor object. The method requires a Recordset or SortedRecordset object parameter, and it may have a LoopLockStrength parameter.

Available as of Sirius Mods version 7.6, the New method is an alternative to using the (Recordset or SortedRecordset) Cursor constructor, as described in "Declaration and instantiation".

Syntax

%recordsetCursor = [%(RecordsetCursor In filOrGrp name):]New( recordset, - [LoopLockStrength= lockStrength])

Syntax terms

%recordsetCursor A RecordsetCursor object.
[%(RecordsetCursor In filOrGrp name):] The optional class name in parentheses denotes a Constructor. See "Usage notes", below, for more information about invoking a RecordsetCursor Constructor.
recordset A required Recordset or SortedRecordset object.
LoopLockStrength This optional, name required, parameter is a LockStrength enumeration setting the minimum lock strength for a record in a For Record At loop on a RecordsetCursor object. Options are None (default), Share, or Exclusive, further described in CurrentRecord.

For more information about loop lock strength, see "LoopLockStrength for RecordsetCursors".
Note: This parameter is only valid if recordset is a Recordset object.

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:

    %rscursor = new %rscursor = %(RecordsetCursor in group fleet):new %rscursor = %rscursor:new

    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 RecordsetCursor variable's declaration.

  • If recordset is empty, New returns a RecordsetCursor object with the state Empty. This is different from the Cursor methods of instantiation, which return a null if %recset is empty.
  • When a RecordsetCursor is instantiated, it is automatically positioned on the first record in the set (state=HasRecord).
  • You can have as many cursors as you want for a RecordsetCursor.
  • If you are creating an extension class of the RecordsetCursor class, you can use New in the Construct statement in the extension class:

    class myrecSetCurse extends RecordsetCursor - in file test inherit ... constructor new construct %(RecordsetCursor):new(%sortedRecset) ... end constructor ... end class

    The Cursor Recordset function cannot be used for this purpose.

See also