× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: page n of x
  • From: James David Rich <james@xxxxxxxxxxxxx>
  • Date: Wed, 13 Sep 2000 17:01:34 -0600 (MDT)

On Wed, 13 Sep 2000, Gary Guthrie wrote:

> I guess I'm not understanding. I don't see why you have to pass the
> number of pages. See if I've got the scenario correct.

I need to know when to stop scanning the user space.  The scenario below
is perfect:

> You spool a 3 page report so that you have
> 
> Page 1 of ~~~~
> .
> .
> .
> 
> Page 2 of ~~~~
> .
> .
> .
> 
> Page 3 of ~~~~

Now this report is put into a user space.  Now I scan the user space using
the following code:

DUSRSPCNAM        S             20    INZ('JAMES     JAMES     ')
DUSRSPCPTR        S               *
Dptrsave          S               *
DUSERAREA         DS                  BASED(USRSPCPTR)
D CHARFIELD               1   1024
DQUSEC            DS
D QUSBPRV                 1      4B 0
D QUSBAVL                 5      8B 0
D QUSEI                   9     15
D QUSERVED               16     16
C*
C                   Z-ADD     16            QUSBPRV
C                   CALL      'QUSPTRUS'
C                   PARM                    USRSPCNAM
C                   PARM                    USRSPCPTR
C                   PARM                    QUSEC
C     QUSBAVL       IFGT      0
C                   DSPLY                   QUSEI
C                   ELSE
C                   eval      ptrsave = usrspcptr
C                   clear                   totalpages        4 0
C*
C                   dow       ??????????????
                              ^^^^^^^^ I don't know when to stop
C                   clear                   position          4 0
C     '~~~~'        scan      userarea      position
C*
C     position      ifne      *zeros
C                   add       1             totalpages
C                   endif
C*
C                   eval      usrspcptr = usrspcptr + 1024
C                   enddo
C*
C                   eval      usrspcptr = ptrsave
C                   clear                   pagecount         4 0
C*
C                   dow       pagecount < totalpages
C                   clear                   position
C     '~~~~'        scan      userarea      position
C*
C     position      ifne      *zeros
C                   eval      %subst(userarea:position:4) =
C                             %trim(%editc(totalpages:'3'))
C                   add       1             pagecount
C*
C                   else
C                   eval      usrspcptr = usrspcptr + 1024
C                   endif
C*
C                   enddo
C*
C                   ENDIF
C*
C                   SETON                                        LR
C                   RETURN


If any of this looks familiar it is because the stuff in caps is copied
right out of the IBM system api manual.  Please keep in mind that this
code is ugly - first, quick attempt at a solution.

The dow loop followed by ????? needs to know when to end.  I can't
increment the pointer past the end of the user space.  I don't know ahead
of time how many pages there should be.  What I really need is something
similar to the C function:

        while (fscanf(file, "%s", buffer) != EOF)
                {do some work}

Another problem with the above code is what happens if the ~~~~ occur on
the 1024 byte boundary?  If I only get 2 '~'s at the end of the USERAREA
buffer the scan won't work.

> You then use the utility to get the total number of pages - now,
> TotPages = 3

This is what I'm not sure how to do.  Everything else mentioned below I am
doing.

> You then have a program that scans for ~~~~ and replaces it with
> TotPages

[Cut for brevity]

James Rich
james@dansfoods.com

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.