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



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.

----- Original Message ----- From: Lim Hock-Chai
To: RPG programming on the AS400 / iSeries
Sent: Tuesday, August 29, 2006 5:17 PM
Subject: RE: Allocate field with options(*nopass :*omit)


Use below as example:

If piParm1 is not passed, I normally have to create a temporary variable
(myParm1) to use it later in the procedure.
p test            B
d                 pi
d  piParm1                      10a   options(*nopass) const

d myParm1         s                   like(piParm1)

c                   if        %parms() >= 1
c                   eval      myParm1 = piParm1
c                   endif

c         if        myParm1 = *blank
C    .... Do something
C   else
C                     .... Do something else
C                   endif

p test            E

I would prefer to be able to do something like below
p test            B
d                 pi
d  piParm1                      10a   options(*nopass) const

c                   if        %parms() >= 1
c                   alloc     %size(piParm1) piParm1

c                   endif

c         if        piParm1 = *blank
C    .... Do something
C   else
C                     .... Do something else
C                   endif

p test            E

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

Not sure what you're looking for. Procedures don't allocate memory for
parameters that are passed in. What are you trying to accomplish?
 ----- Original Message -----
 From: Lim Hock-Chai
 To: RPG programming on the AS400 / iSeries
 Sent: Tuesday, August 29, 2006 4:50 PM
 Subject: Allocate field with options(*nopass :*omit)


 Is there a way for procedure to allocate memory for entry parm field
 that is not being pass in by the caller?

 example:
 d testPrc         pr
 d  piParm1                      10a   options(*nopass) const




 --
 This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
 To post a message email: RPG400-L@xxxxxxxxxxxx
 To subscribe, unsubscribe, or change list options,
 visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
 or email: RPG400-L-request@xxxxxxxxxxxx
 Before posting, please take a moment to review the archives
 at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.



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.