# PROCESS PAGE in a REPEAT loop

**URL:** <https://techcommunity.softwareag.com/t/process-page-in-a-repeat-loop/80617>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, NaturalONE, Natural-for-AJAX\
**Created:** [March 27, 2009, 5:05pm UTC](https://techcommunity.softwareag.com/t/process-page-in-a-repeat-loop/80617 "2009-03-27T17:05:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Schwade](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/thomas_schwade/32/131_2.png) [@Thomas\_Schwade](https://techcommunity.softwareag.com/u/Thomas_Schwade)\
**Post date:** [March 27, 2009, 5:05pm UTC](https://techcommunity.softwareag.com/t/process-page-in-a-repeat-loop/80617/1 "2009-03-27T17:05:25Z")

</div>

More often than not, a Natural application organizes its I/O processing in a REPEAT loop. Doing this with Natural for Ajax, we would result in a program structure like the following:

```auto

DEFINE DATA LOCAL
1 MESSAGE (A) DYNAMIC
END-DEFINE
*
REPEAT
*
  PROCESS PAGE USING "A3392"
*
  DECIDE ON FIRST *PAGE-EVENT
*
    VALUE U'nat:page.end'
      IGNORE
*
    VALUE U'onButton1'
      MESSAGE := 'Button 1 was pressed.'
      ESCAPE TOP
*
    VALUE U'onButton2'
      MESSAGE := 'Button 2 was pressed.'
      ESCAPE TOP
*
    VALUE U'onButton3'
      MESSAGE := 'Button 3 was pressed.'
      ESCAPE TOP
*
    NONE VALUE
      PROCESS PAGE UPDATE
*
  END-DECIDE
*
END-REPEAT
*
END
```

However, we are not able to set a message in the status line with this code structure, because the PROCESS PAGE statement lacks a SEND EVENT clause. An option to overcome this situation is setting the status message in an extra event that is triggered by a timer control, as shown below:

```auto

DEFINE DATA LOCAL
1 SHOWMESSAGE (A) DYNAMIC
1 MESSAGE (A) DYNAMIC
END-DEFINE
*
REPEAT
*
  PROCESS PAGE USING "A3392"
*
  DECIDE ON FIRST *PAGE-EVENT
*
    VALUE U'nat:page.end'
      IGNORE
*
    VALUE U'onButton1'
      MESSAGE := 'Button 1 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onButton2'
      MESSAGE := 'Button 2 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onButton3'
      MESSAGE := 'Button 3 was pressed.'
      SHOWMESSAGE := '1'
      ESCAPE TOP
*
    VALUE U'onShowMessage'
      SHOWMESSAGE := '0'
      PROCESS PAGE UPDATE FULL
        AND SEND EVENT 'nat:page.message'
        WITH PARAMETERS
          NAME 'type' VALUE 'S'
          NAME 'short' VALUE MESSAGE
        END-PARAMETERS
*
    NONE VALUE
      PROCESS PAGE UPDATE
*
  END-DECIDE
*
END-REPEAT
*
END
```

This method costs an additional roundtrip to the server, but allows to overcome the above restriction. The full example code is contained in the attached zip file.  
[NRT3392.zip](https://techcommunity.softwareag.com/uploads/short-url/icz11enQwumGyTQZMXwunApEpel.zip) (15.6 KB)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:51pm UTC](https://techcommunity.softwareag.com/t/process-page-in-a-repeat-loop/80617/2 "2021-04-02T14:51:44Z")

</div>

Closed on April 2, 2021, 2:51pm UTC


