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



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> 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
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: 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 for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.