|
Hans, I can't read that code? Is it written is some advanced language? <vbg> Bob Cozzi cozzi@rpgiv.com Visit the new on-line iSeries Forums at: http://www.rpgiv.com/forum > -----Original Message----- > From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On > Behalf Of boldt@ca.ibm.com > Sent: Wednesday, December 12, 2001 8:13 AM > To: rpg400-l@midrange.com > Subject: Re: FOR op-code > > Tom wrote: > >Second the idea about %TRIM. > > Your wish is my command! Here's an RPG procedure that implements > an extended trim operation: > > //===============================================================// > // Procedure: trimx // > //---------------------------------------------------------------// > // Trim specified characters from string. // > // // > // Parameters: // > // I: string - string to trim // > // I: chars - list of characters to trim // > // // > // Returns: trimmed string // > // // > //===============================================================// > P trimx b > D trimx pi 1000a varying > D string 1000a const varying > D chars 256a const varying > D start s 10i 0 > /free > start = %check(chars:string); > if start = 0; > return ''; > endif; > return %subst(string: start: %checkr(chars:string) - start + 1); > /end-free > P trimx e > > Just put the prototype into a /copy member, compile the procedure, > and put in into a service program, and you've got your enhancement! > (I'll leave it to you to implement "trimxl()" and "trimxr()".) > > > >But since we're on the subject of > >wish-lists... > > >I wish the FOR op-code did away with the TO/DOWNTO and instead looked at > the > >sign of the BY increment. There would also have to be a change in the way > >the limit value and the index are compared. > > > >So that I can fill an array 'forwards' or 'backwards', for instance. > This > >seems more 'natural' to me. > > Since that might cause existing FOR loops to behave differently, > this isn't going to happen. With the current syntax, it is clear > exactly which direction the loop interates. > > One problem with the proposal is what happens when the sign of > the increment variable changes during the looping? The limit > test would also change sense, and would likely cause the loop > to exit earlier than expected since the index value would now > be on the other side of the limit value. > > Cheers! Hans > > Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l > or email: RPG400-L-request@midrange.com > 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 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.