× 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.



Ahh, okay, what you need to do is to pass the totalpages INTO the program 
someway.  Your
original program (the one that created the spool file in the first place) 
should know the total number
of pages (look at your PAGE variable).  When you call this program pass it the 
parameter of PAGE
(which should be the last page number, make sure it's not last page number + 1 
though).

Then you can get rid of the first half of this program where you are counting 
the pages.
Then just start your logic at the
dow pagecount < totalpages.

You are making 2 passes though the user space in this program, you should only 
have
to do one pass.

Regards,

Jim Langston

James David Rich wrote:

> 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
> +---

+---
| 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 ...

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.