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



On 2/22/2017 10:26 AM, Englander, Douglas wrote:
Does anyone have an edit code or edit word they can share that will add a 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.


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.