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



I might be wasting my time to gain some insignificant amount of
efficiency.  Here is my thought: Using below as an example, won't it be
a waste of cpu to have to copy those two big optional fields to
temporary fields for every single execution?

     p example         B                   export
     d                 pi            10i 0 opdesc
     d  piParm1                   32767    const
options(*varsize:*nopass:*omit)
     d  piParm2                   32767    const
options(*varsize:*nopass:*omit)

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Peter Levy
Sent: Wednesday, August 30, 2006 8:56 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Allocate field with options(*nopass :*omit)

Unfortunately what you want to do can't really be done. Given that your
parameter is a constant you can only have a local variable with a
default value (as has already been suggested). If you changed your
parameter by removing the "const" keyword you could do something like
this:

     P test            B

     D test            pi
     D  piParm1                      10a   options(*nopass)

     D pi              s                   like(piParm1) based(piPtr)
     D piPtr           s               *   inz(*null)

     C                   if        %parms() >= 1
     C                   eval      piPtr = %addr(piParm1)
     C                   else
     C                   alloc     %size(piParm1)piPtr
     C                   endif

     C                   if        pi = *blank
     C*                    .... Do something
     C                   else
     C*                    .... Do something else
     C                   endif

     C                   if        %parms() < 1
     C                   dealloc(n)              piPtr
     C                   endif

     p test            E

However it's hardly worth the effort. Better to use the local variable.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.