|
On 2/22/2017 10:26 AM, Englander, Douglas wrote:
Does anyone have an edit code or edit word they can share that will adda floating plus sign for a positive number?
I can't say I've ever seen this request before. Out of idle curiosity,
why?
Anyway, answering your question was harder than I thought.
RPG has no native facility to create floating signs, and neither does
DDS. I even looked at the edit APIs (QECEDT and friends), but they seem
based on the EDTWRD facility in DDS. Finally I turned to MI, and
edit_packed(). That can handle floating signs.
The MI Library Reference:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_61/
rzajp/sc092418.pdf
Search for 'edit_packed' without the quotes. There's a nice example in
C which compiled and ran fine. But since this is the RPG list, here is
the same example in RPG:
**free
// edit a number using MI
/copy qrpglesrc,stdhspec
dcl-pr edit_packed extproc('edit_packed');
dest char(128);
destLen uns(10) value;
src pointer value;
srcLen uns(10) value;
mask pointer value;
maskLen uns(10) value;
end-pr;
dcl-s dest char(128);
dcl-s src packed(10: 0) inz(12652);
dcl-s mask char(18) inz(x'34b1404e346034b2b2b2b2b2b2b2b2b2b2b2');
dcl-s msg char(50);
edit_packed(dest: %len(src)+1: %addr(src): %len(src): %addr(mask):
%size(mask));
msg = '>>' + %subst(dest: 1: %len(src)+1) + '<<';
dsply msg;
msg = %editw(src: ' 0 +');
dsply msg;
*inlr = *on;
The description of the mask can be found at the original MI reference:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzatk/EDIT.htm
34 - string terminator
B1 - start floating section
40 - fill
4E - positive string
34 - end of positive string
60 - negative string
34 - end of negative string
B2 - one per digit of source field
Do note that there are 11 x'b2' digits. That's because a packed 10
field actually has 11 digits.
--
--buck
Try wiki.midrange.com!
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
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.