$FieldgroupOccurrence: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Mlarocca moved page $FIELDGROUPOCCURRENCE to $FieldgroupOccurrence: Lower case change)
 
(2 intermediate revisions by one other user not shown)
Line 21: Line 21:
<li>In a large record, <var>$FIELDGROUPOCCURRENCE</var> is expensive. It intentionally scans from the start of the record, in case there were additions or deletions of the fieldgroup.  
<li>In a large record, <var>$FIELDGROUPOCCURRENCE</var> is expensive. It intentionally scans from the start of the record, in case there were additions or deletions of the fieldgroup.  
<p>
<p>
For example, say that a record being processed in an <var>FEO FIELDGROUP</var> loop has thousands of occurrences of a fieldgroup. In this case, invoking <var>$FIELDGROUPOCCURRENCE</var> for each iteration of the loop will be prohibitively expensive, and you can save significant processing resources if you label the FEO loop and substitute a simple <code>OCCURRENCE IN <i>label</i></code> statement for the <var>$FIELDGROUPOCCURRENCE</var> statement: </p>
For example, say that a record being processed in an <var>FEO FIELDGROUP</var> loop has thousands of occurrences of a fieldgroup. In this case, invoking <var>$FIELDGROUPOCCURRENCE</var> for each iteration of the loop will be prohibitively expensive, and you can save significant processing resources if you label the FEO loop and substitute a simple <code>OCCURRENCE IN <i>label</i></code> statement for the <var>$FIELDGROUPOCCURRENCE</var> statement, as shown in the following fragment: </p>


<p class="code">Begin
<p class="code">Begin
  ...
  ...
  example1: feo fieldgroup Foo
example1: feo fieldgroup Foo
   
   
              %id        = Foo.ID
            %id        = Foo.ID
              %code      = Foo.CODE
            %code      = Foo.CODE
              %text      = Foo.TEXT
            %text      = Foo.TEXT   
              <s>%occurrence = $fieldGroupOccurrence</s>    
            %occurrence = occurrence in example1   /? was $fieldGroupOccurrence ?/
              %occurrence = occurrence in example1
          end for
            end for
  ...
  ...
End
End

Latest revision as of 17:43, 21 July 2014

This function returns the current occurrence number of the field group. If the current field group has been deleted, $FIELDGROUPOCCURRENCE returns 0.

$FIELDGROUPOCCURRENCE is available as of Model 204 version 7.5.

Syntax

%num = $FIELDGROUPOCCURRENCE

Example

FOR EACH OCCURRENCE OF FIELDGROUP REDSOX PRINT $FIELDGROUPOCCURRENCE CALL CHANGINGPROC PRINT $FIELDGROUPOCCURRENCE END FOR

This example might print a different value before and after calling the CHANGINGPROC procedure, if that procedure inserted or deleted the field group occurrence before the current one.

Usage notes

  • In a large record, $FIELDGROUPOCCURRENCE is expensive. It intentionally scans from the start of the record, in case there were additions or deletions of the fieldgroup.

    For example, say that a record being processed in an FEO FIELDGROUP loop has thousands of occurrences of a fieldgroup. In this case, invoking $FIELDGROUPOCCURRENCE for each iteration of the loop will be prohibitively expensive, and you can save significant processing resources if you label the FEO loop and substitute a simple OCCURRENCE IN label statement for the $FIELDGROUPOCCURRENCE statement, as shown in the following fragment:

    Begin ... example1: feo fieldgroup Foo %id = Foo.ID %code = Foo.CODE %text = Foo.TEXT %occurrence = occurrence in example1 /? was $fieldGroupOccurrence ?/ end for ... End