MAP Handling for PF7 and PF8

How to define page up and page down in map ? If there are 100 records and I need to throw only 10 at a time?

As per my understanding I need to use READ ISN for the file. Read first 10 records and save *ISN of last record. Create two separate subroutines for PAGE-DOWN and PAGE-UP.
If PF8 is pressed Perform PAGE-DOWN. In PAGE-DOWN subroutin, do READ ISN from the stored ISN
IF PF7 is pressed Perform PAGE-UP. But here I have no idea how to read file in reverse order.

Please help on this. Is my approach is correct or there is any other way. I remember I had created such application in past around 6 years back. But now can recall.

Twenty years ago I wrote the attached article for Inside Natural. It is of most use when the user will be scrolling through most of a list. However, the problem you described fits this rather well.

There are many ways (one suggested at the end of the article) to embellish the code and make it more user friendly.

Since there is a limit of 3 attachments, (and a total size restriction), I will attach two here, and two to a subsequent posting.

Okay, that is not working. I am getting a message that the size was exceeded by the first pdf page. I will try to do four postings.

Okay, that did not work either. I will contact the forum administrators to see if this can be reconciled

While waiting for info on how to avoid the size restriction, you might want to do this yourself.

Read all 100 records into an array dimensioned, say, as NAME (1:10).

In the map editor, define the NAME array as vertical with ten entries from #START to #START+9.

Write processing rules. If the user hits PF8, add ten to #START. If PF7, subtract 7.

Have a place for the user to enter a number 1 to 10, which corresponds to a column on the screen which is to the left of the ten names. If there is an entry here, process that record, or whatever you want to do with it.

This approach eliminates the “back and forth” approach where you start in the program, go to the map, then if the user hits pf8, goes back to the program to reload a ten position array, then back to the map, ad nauseum.

Array we have option if we have only 100 records or bit more… But what if records are in millions?

If you have millions of records, you clearly do not implement this as suggested.

When the article mentioned earlier gets posted, you will see there is a processing rule for a PF key which scrolls forward. If the user tries to scroll past the limit of the array, you would refill the array with the next 100 records. Or, you might keep 50 records from the last 100 (so the user can scroll backwards into the last group) and add 50 new records.

Okay! So if we have reached 100K records by scrolling down we can’t come to Top by scrolling up… right?

If there is any parameter to read backward this challenge can be resolved.

WRONG!!!

If such a capability is required, you write code to do it. You have an field on the screen where a user can enter a value (if it involves a READ LOGICAL), or an ISN (READ BY ISN) or something like TOP or HALF (Physical sequential).

You could also have a PF key for establishing a “bookmark” that you can return to.

Programming is not just knowing the syntax of statements. It is about figuring out how to best address a users needs using the facilities of whatever language/platform you are using. Okay, it is also sometimes about figuring out what the best language/platform is for a particular system.

Natural is a VERY powerful development platform. Unfortunately, many, many programmers do not use the full spectrum of capabilities. This is indeed sad.

Before Natural introduced the DESCENDING/ASCENDING parameters on the read loop we solved the paging problem by saving the key to the first record of each page in an array and when the user pressed the page-back key (PF4 in our system) we just restart the read from the last key in the array and then remove that occurrence.

With the DESCENDING option, I would probably code it to just read backwards and fill the display array from the bottom up.

This assumes you are reading in LOGICAL sequence; READ BY ISN does not have a DESCENDING option.

Okay. I am going to try and post the four pages mentioned above. This will be done in two postings. Here are the first two pages.

scroll1.pdf (922 KB)
Scroll2.pdf (855 KB)

And here are the last two pages:
Scroll4.pdf (713 KB)
Scroll3.pdf (790 KB)