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



Scott, 

I must have been completely blind... 
To be honest, I even can't remember anymore why I introduced the pointer
(un)logic in my procedures.
I really messed it up in my brain, made to much hours this week I think.

Thanks for helping me out!
Regards, Arco.

> -----Oorspronkelijk bericht-----
> Van: rpg400-l-bounces@xxxxxxxxxxxx 
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Namens Scott Klement
> Verzonden: vrijdag 2 september 2005 21:18
> Aan: RPG programming on the AS400 / iSeries
> Onderwerp: Re: *varsize array as procedure parameter
> 
> 
> > - define a *varsize array as parameter.
> > - define another parameter that contains the amount of 
> array indexes.
> > - in the procedure I have declared the same array with 32767 
> > dimensions as based, so it won't waste space.
> 
> Why are you re-declaring the array based on a pointer?!  Why 
> not simply reference the parameter?
> 
> In other words, why not make the Search subprocedure work like this?
> 
>       p Search          B
>       d Search          PI             5U 0
>       d  peCode                        5A   const
>                                             dim(32767)
>       d                                     options(*varsize)
>       d  peElem                        5U 0 const
>       d  peArgm                        5A   const
> 
>       d i               S              5U 0
> 
>        /free
>         for i = 1 to peElem ;
>           if peCode(i) = peArgm ;
>             return i ;
>           endif ;
>         endfor ;
>         return 0 ;
>        /end-free
>       p Search          e
> 
> That way, you can use CONST to make it clear that the 
> subprocedure doesn't update the array, and you also save a 
> few lines of code, including eliinating unnecessary pointer logic.
> 
> I don't understand why you did it the way you did?
> 
> > I cannot use the array parameter as const (no pointer to const parm
> > possible) or value (*varsize not allowed with value parm).
> 
> But... the pointer was unnecessary, so you could make it 
> CONST without a problem.  I agree that VALUE doesn't make 
> sense, if you used VALUE it'd make a copy of the array, which 
> would add unnecessary overhead to the routine.
> 
> > Is there a way to protect the original array other than by 
> copying it?
> > And if I have to copy it locally what is the best way to do 
> so. Using 
> > the heap?
> 
> You don't have to copy it.  But, if you did, you may as well 
> use VALUE and let the compiler do the work.
> 
> > Am I missing somewhat somewhere?
> 
> Yes, you're missing that the pointer logic is unnecessary :)
> 
> --
DISCLAIMER:
This message contains information that may be privileged or confidential and is 
the property of the sender. 
It is intended only for the person to whom it is addressed. If you are not the 
intended recipient, you are not 
authorized to read, print, retain, copy,disseminate, distribute, or use this 
message or any part thereof. If you
receive this message in error, please notify the sender immediately and delete 
all copies of this message. 

This footnote also confirms that this email message has been swept of the 
presence of computer viruses



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.