× 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 didn't want to use varying because I though at run time it will always
allocate the max size of the field.  Another word, if caller pass only
one char to the procedure, at the time, this procedure will still
allocate 32767 byte of memory.  

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Thursday, August 31, 2006 3:47 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Allocate field with options(*nopass :*omit)

Lim Hock-Chai wrote:

If CEEDOD is a slow polk then is there a point of using
options(*varsize) on const?

If you use options(*varsize), you must call CEEDOD to see how much of
the parameter you can use.  (Unless the caller passed another parameter
giving the length.)

Someone else suggested using VARYING instead of options(*varsize). 
That's a good idea, because you wouldn't have to call CEEDOD, and the
cost of copying the parameter to your temporary would depend on the
length of the parameter.

       p example         B                   export
       d                 pi            10i 0 opdesc
       d  piParm1                   32767    const varying
       d                                     options(*nopass:*omit)
       d  piParm2                   32767    const varying
       d                                     options(*nopass:*omit)
 
       d  myParm1        s                   like(piParm1) 
       d                                     inz(defaultvalue)
        /free

         if (%parms >= 1 and %Addr(piParm1) <> *Null);
           myParm1 = piParm1;
         endif;        

If you define myParm1 as static, to avoid having the automatic variable
allocated on every call, do it like this.

       d  myParm1        s                   like(piParm1) 
        /free

         if (%parms >= 1 and %Addr(piParm1) <> *Null);
           myParm1 = piParm1;
         else;
           myParm1 = defaultvalue;
         endif;

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

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.