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



>From: rob@dekko.com
>Date: Tue, 15 Jan 2002 13:31:58 -0500
>
>I've poured over that call but can't figure out what it does.

Rob, say you have a procedure that takes lines of data and
prints them out.  Now, say you have several different ways of
getting the data.

Rather than pass in several different parameters to control
the way that the data is fetched, you could write your printIt
procedure to take an extra parameter: a procedure pointer for
a procedure that supplies data.

This extra parameter is called a callback, because the called
procedure will call back to the procedure in the parameter
when it needs some data.

For example, say you have two procedures (they need to have an
identical interface - it would be good to use LIKE as much
as possible here, probably with the LIKE types defined in
the same copy file as the prototype for the main processing
procedure (printIt in this example)):

D getDsply      PR            80A
D   eof                         N

D getFile       PR            80A
D   eof                         N

Here's what getDsply might look like:

P getDsply      B
D getDsply      PI            80A
D   eof                         N
D line          S             52A
C        DSPLY         line
C        if      line = 'Q'
C        eval    eof = '1'
C        return  ' '
C        endif
C        return  line
P               E

getFile would be similar, but it would use READ instead
of DSPLY to get the data.

Your printIt procedure might look like this:

P printIt       B
D printIt       PI
 * Here's the callback procedure pointer
D   getLineP                    *  PROCPTR
 * Here's the prototype to use the callback function
D getLine       PR            80A  EXTPROC(getLineP)
D   retEof                      N
D eof           S               N
D line          ds            80
C          dou      eof
 * Here we're calling the callback function
C          eval     line = getLine(eof)
C          if       not eof
C          write    qsysprt       line
C          endif
C          enddo
P               E

Barbara Morris



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.