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



Hi Carlos,

I don't see any problems with the array.   However, you've got a number
of parameters where you're passing pointers by reference.   The API isn't
expecting to receive pointers by reference, it's expecting to receive
character strings by reference.  (i.e. Char(*))

These are the parameters that I'm suggesting are wrong:

> d  ExportName...
> d                                 *   const options(*string)
> d  ReturnValue...
> d                                 *   options(*nopass)
> d  Parameter1...
> d                                 *   options(*nopass)
> d  Parameter2...
> d                                 *   options(*nopass)
> d  Parameter3...
> d                                 *   options(*nopass)

When you pass something by reference (which is what you do anytime you
omit the "value" keyword from a prototype) what actually gets passed to
the procedure or program that you're calling is the ADDRESS OF the
variable.

So, you've got an integer called 'Rtn'.   pRtn is a pointer that contains
the address of Rtn.  BUT, since you're passing pRtn by reference, you're
passing the address of pRtn!   On the other hand, had you passed the VALUE
of pRtn, you'd be passing the address of Rtn... which is what you want.

Unfortunately, you're not allowed to pass parameters to EXTPGM prototypes
by value.   So, instead, you need to pass your integers by reference
directly.

I hope all of that makes sense, it's really hard to put into words.

Here's a sample that calls the ILE C system() function.  (I could not use
your example, since I do not have that service program!)

     D DS_P_Error      DS
     D zBytp                         10I 0 inz(%size(P_Error))
     D zByta                         10I 0
     D zErrid                         7
     D zError                         1
     D zExdta                       240
     D P_Error                      256    overlay(DS_P_Error)

      * el formato de los parametros (todos enteros)
     d array           s             10i 0 dim(1) inz(2)

     d qzruclsp        pr                  extpgm('QZRUCLSP')
     d  QualSrvPgm...
     d                               20a   const
     d  ExportName...
     d                             4096A   options(*varsize) const
     d  ReturnValueFormat...
     d                               10i 0 const
     d  ParametersFormat...
     d                               10i 0 const dim(1)
     d  NumberOfParameters...
     d                               10i 0 const
     d  ErrorCode...
     d                              256a
     d  ReturnValue...
     d                               10I 0 options(*nopass)
     d  Parameter1...
     d                              100A   options(*nopass)

     D cmd             s            100A
     D rtn             s             10I 0

     c                   eval      cmd = 'DSPLIBL' + x'00'
     c                   callp     qzruclsp('QC2SYS    QSYS  ':
     c                                      'system'+x'00':
     c                                      1: array: 1: p_error:
     c                                      Rtn: cmd)
     c*                  callp     SndAPIErr(p_error)
     c                   if        zByta > 0
     c     'error'       dsply                   zErrid
     c                   else
     c     'success'     dsply                   Rtn
     c                   endif
     c                   eval      *inlr = *on

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.