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



Lim,
I still don't get what you're trying to do.
Basically if a parameter is CONST, it is the most efficient way to pass
parameters. This is because the compiler will pass the parameter data by
reference. If possible, a %SUBST()-like function is used to pass the data when
the parameter is a different length from the data itself.
If you want to be able to pass a null-pointer, then OPTIONS(*OMIT) allows you to
specify *OMIT in place of a parameter variable. Then down in your code you would
check the address of the parameter for *NULL, as follows:

   If %addr(piParm1) = *NULL;  // *OMIT was specified!

   Endif;

Of course if the parameter is CONST, this technique will require the lastest
release of OS/400 to work properly. If you are on V5R1 or earlier, use the
CEETSTA API to check to see if the parameter is passed. In fact, I continue to
use CEETSTA instead of the %addr()=*NULL thing just to make sure things work.

-Bob Cozzi
www.iSeriesTV.com
Ask your Manager to watch iSeriesTV.com


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Lim Hock-Chai
Sent: Wednesday, August 30, 2006 9:24 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Allocate field with options(*nopass :*omit)

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

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.