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



Using that example, you could, if you wanted, use *zeros instead of a line of 0's:
coldta = %subst( *zeros: 1: cwdth( #col ) - %len( coldta ) ) + coldta;

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Arthur Marino
Sent: Wednesday, March 25, 2009 2:08 PM
To: RPG programming on the IBM i / System i
Subject: RE: Using an Expression to control a FOR loop

I just went back to the manual and it's true that you CAN'T specify
variable names for the 2nd (length) and 3rd (dec pos) parms of %dec.
Unless they represent values that are known at compile time. These 2
values aren't known until run time so my code needed to be more
flexible.

Now that it's been pointed out to me that the entire FOR expression is
evaluated at the 'endfor' (I thought it was evaluated once and just
tested at 'endfor'), I see why it didn't work at first. I still like
Terry's solution 'cause it's fewer instructions than mine and 123
correctly becomes 00123.

coldta = %subst( '000000000000000' // "lots" of zeros
: 1
: cwdth( #col ) - %len( coldta )
) + coldta;

Arthur J. Marino
RockTenn Corporation
(631) 297-2276

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Douglas Handy
Sent: Wednesday, March 25, 2009 2:13 PM
To: RPG programming on the IBM i / System i
Subject: Re: Using an Expression to control a FOR loop

Alan,

And I don't believe (PLEASE CORRECT ME IF I'M WRONG) I can code " ColDta
= %Editc(%Dec(%Trim(ColDta):VARIABLE_WIDTH:VARIABLE_DECPOS):'X')".


What I'd suggest is you move the "editing" to a subprocedure where you
can
hide the complexity. That way your inline code stays cleaner and more
readable (assuming a properly named procedure). Pass the desired length
and
decimals to the subprocedure, and your inline code should be readable.

Then do whatever you have to in the procedure, and comment it as
necessary
so the next guy can follow it. But at least the ugly code will be
localized.

One thing the procedure could do is call QECCVTEC to create an "edit
mask"
using a passed in length, decimals, edit code, etc. Then that edit mask
(which you can re-use) can be passed to QECDT to perform the actual
editing
of the field. But those APIs may make more sense if you needed fancier
editing with thousand separators, currency symbols, etc.

To just pad with zeros, it may be easier for the next guy to follow some
comments with zero padding then the edit APIs.

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


This message, including its attachments, constitutes an electronic communication within the meaning of the Electronic Communications Privacy Act, 18 U.S.C. Section 2510. This message is the confidential property of RockTenn, and disclosure is strictly limited to recipients intended by the sender. Unless previously authorized in writing, this message does not constitute an offer, acceptance, or agreement of any kind. This message may contain confidential attorney-client privileged information and attorney work product. If you are not the intended recipient, or responsible for delivering e-mail to the intended recipient, you are advised that use, dissemination, forwarding, printing, or copying of this message is STRICTLY PROHIBITED. If you receive this message in error, please notify the sender immediately by return e-mail and delete the message entirely from your system. Sender is not liable for damage caused by viruses transmitted with this message, or errors or omissi!
ons in content caused by transmission.
(c) RockTenn, Norcross, GA.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.