Perzactly! James' point is correct, to a degree - trailing blanks are not truncated using EVALR, although he might think they should - he didn't exactly say one way or the other.


It's been so long since I've used MOVE, but seems to me it does not strip trailing blanks - do I remember that rightly?


Now if your small_var were a varchar(7), the evalr on its own would have right-justified it, all by itself.


Regards
Vern


On Wed, 15 Feb, 2023 at 8:25 AM, Gerald Magnuson <gmagqcy.midrange@xxxxxxxxx> wrote:


To: rpg programming on ibm i

just to show my work:

DCL-S big_var CHAR(15);
DCL-S small_var CHAR(7);
*
small_var = 'TEMP1' ; // small_var = 'TEMP1 '
evalr big_var = small_var ; //big_var = ' TEMP1 '
evalr big_var = %trimr(small_var); //big_var = ' TEMP1'
*inLR = *on ;

On Wed, Feb 15, 2023 at 5:57 AM Vern Hamberg via RPG400-L <
rpg400-l@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxxxxxxxx>> wrote:

Hi James

Nothing wrong with EVALR that I can see - it has to be used rightly,
though - FOO is a fixed-length variable, so all those trailing blanks
are part of it - you are trying to right-justify a 50-char value into a
50-char variable - and that is what you got. The DSPLY of BAR is correct.

According to the documentation for EVAL and EVALR - the former is padded
or truncated on the right - the latter is padded or truncated on the
left - EVALR does not strip trailing blanks, just as EVAL does not strip
leading blanks - interesting, eh?

Cheers
Vern

On 2/14/2023 5:03 PM, James H. H. Lampert via RPG400-L wrote:
On 2/14/23 2:27 PM, Roger Harman wrote:
Why on earth would you do all that manipulation when a simple opcode
does the job?

Because that simple opcode *doesn't* do the job by itself.

Consider:

D FOO S 50A
D BAR S 50A
D BAZ S 50A
C EVAL FOO = 'FOOBAR'
C EVALR BAR = FOO
C EVALR BAZ = %TRIM(FOO)
C FOO DSPLY
C BAR DSPLY
C BAZ DSPLY
C SETON

If you compile and run this, you get:

DSPLY FOOBAR
DSPLY FOOBAR
DSPLY FOOBAR

If the EVALR were *all* it took to forcibly quad a string to the
right, then the second line of the output would look like the third,
not the first.

As to explicitly adding spaces on the left, that would only be
necessary if you were using a version of ILE RPG that lacked the EVALR.

--
JHHL

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

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related
questions.



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.