|
keep in mind, you don't need to re-write your entire system to take advantage of the features of RPG IV/ILE. for example, what i've done on many occasions is to develop a set of procedures that i'll create a service program from. RPG IV programs can then use those procedure as they need. i'll then write a "wrapper" routine that does nothing more than take in a set of parms, call the procedure and return the results. i'll create a program from this wrapper, so that the procedures will be available from RPG III programs. in your example, you may want to write a small RPG IV program that does nothing but accept a string as a parameter, perform %trim functions (or other RPG IV string handling functions) against it, and return the result. five minutes of work, you don't need to re-invent the wheel, and you don't have to move everything to RPG IV if your not ready for that. the only potential problem is the performance consideration. an OPM call afterall is comparably very taxing on the CPU. ____________________________ Ed Komeshak mailto:ed@midwareservices.com (810) 296-5572 Midware Services http://midwareservices.com/ > -----Original Message----- > From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On > Behalf Of Buck Calabro > Sent: Monday, January 15, 2001 4:35 PM > To: RPG400-L@midrange.com > Subject: RE: justifying a character variable > > > Lynette Chronister wrote: > > >what is the easiest way to right justify a character variable. > >oh, p.s. im writing in 400 not ILE. > > The easiest (by far) is to use RPG IV: evalr output = %trimr(input) > > Here is an RPG/400 version donated many years ago by Booth Martin. It > handles numbers, but pulling out the IF...END will allow it to handle > characters too: > > E ARI 15 1 > E ARO 15 1 > * ------------------------------------------------------- > IDUMMY DS > I I '1500 ' 1 15 FROM > I I ' ' 16 30 TARGET > I I 0 31 450NUMBER > * ------------------------------------------------------- > C* > C* OK, here's an old-fashioned way to get your string > C* right-adjusted, numbers only > C* Courtesy Booth Martin, Midrange-L mailing list > C* > C* Definitions: > C* FROM A 15 character field that is our original data field. > C* > C* TARGET A 15 character field that is our new, right adjusted, > C* numbers only field. > C* > C* ARI An array; 15 elements each 1 character long, for > C* input. > C* ARO An array; 15 elements each 1 character long, for > C* output. > C* I A 2-digit field for an index of the ARI array. > C* O A 2-digit field for an index of the ARO array. > C* > C* Narrative: We'll move our FROM field into the ARI array and then > C* starting at the end (element 15) we will go backwards. > C* As we go backwards we will check each element of ARI to see if > C* it is a number. If it is a number we will move it to the "O" > C* element of ARO and decrement the index "O" for ARO by 1. > C* When done, we will then move our ARO array to our finish > C* field, TARGET. > C* > * ------------------------------------------------------- > * Set our array indexes (note that we are setting the array index > * at 15 and decrementing it - this gets us right adjusted): > C Z-ADD15 I 20 > C Z-ADD15 O 20 > * Move our "from" field into the array ARI: > C MOVEAFROM ARI > * Read through the array ARI, an element at a time: > C DO 15 > * If the array element is >=0, and <=9, choose it: > C ARI,I IFGE '0' > C ARI,I ANDLE'9' > * It is chosen, and moved to right side of the array ARO: > C MOVE ARI,I ARO,O > C SUB 1 O > C ENDIF > C* > C SUB 1 I > C ENDDO > * Once we are done, move the array ARO to our desired field: > C MOVEAARO TARGET > * Convert to a number > C MOVE TARGET NUMBER > * ---------------------------------------------------------- > * This process will move a field like "A1$2e45(*&6asd7" > * to " 1234567" > * ---------------------------------------------------------- > C DUMP > C SETON LR > > Here is my soapbox: > Your company should be able to see the difference between these > two routines > in terms of clarity, maintainability, adaptability, expandability and > performance. If your company chooses to stay with RPG/400 despite the > obvious benefits, what other obvious benefits is your company withholding > from you? > > Buck Calabro > Aptis; Albany, NY > "Nothing is so firmly believed as > that which we least know" -- Michel Montaigne > Visit the Midrange archives at http://www.midrange.com > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: > david@midrange.com > +--- > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.