Passing Less Data Than Required

When a parameter is prototyped, the compiler will check to see that the length is appropriate for the parameter. If the callee has indicated (through documentation or through that prototype) that a parameter can be shorter than the maximum length, you can safely pass shorter parameters.

Figure 73 shows the prototype for QCMDEXC, where the first parameter is defined with OPTIONS(*VARSIZE) meaning that you can pass parameters of different lengths for the first parameter. Note that OPTIONS *VARSIZE can only be specified for a character field, a UCS-2 field, a graphic field, or an array.

Figure 73. Prototype for System API QCMDEXC with *VARSIZE Parameter
      *-------------------------------------------------------------
      *  This prototype for QCMDEXC defines three parameters.  The
      *  first parameter can be passed character fields of
      *  different lengths, since it is defined with *VARSIZE.
      *-------------------------------------------------------------
     D qcmdexc         PR                  EXTPGM('QCMDEXC')
     D   cmd                       3000A   OPTIONS(*VARSIZE) CONST
     D   cmdlen                      15P 5 CONST
     D                                3A   CONST OPTIONS(*NOPASS)


[ Top of Page | Previous Page | Next Page | Contents | Index ]