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



"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx> wrote on 05/24/2016 08:50:09
PM:
I would go for a "middle-ground" approach and wrapper the
unconventional usage of %xlate in a subprocedure, hopefully in a
"utilities" module where other similar helper procedures are coded.

I agree with the term "unconventional" from the standpoint of the
stated usage in the IBM manuals -- but nothing stronger than that.
Otherwise, I am certainly in favor of documenting the reasons behind
program logic. There is nothing worse than having to change someone
else's code and there is nothing there to explain why they did what they
did. ;-)

So, here is how I have set up my new service procedure for
documentation -- where the prototype goes in a separate copybook, of
course.

* ============================================================== *
* Format up to 26 characters of string data based on a provided *
* template of up to 40 characters in length. The template must *
* be a non-repeating string of the letters of the alphabet where *
* each unique letter corresponds to a character in the input *
* string -- from left to right. If the template format letters *
* are out of order, then the corresponding characters from the *
* input string are transposed accordingly. If a template letter *
* is omitted, then the corresponding character from the input *
* string is dropped from the returned result. Other characters *
* in the template, including blanks, are copied into the result *
* in the same position as they were in the provided template. *
* *
* As an example of transposing and dropping input characters: *
* *
* dcl-s IsoDateStr char(10) inz('1996-02-29'); *
* dcl-s UsaDateStr char(10); // ABCDEFGHIJ *
* UsaDateStr = GenUtl_FormatString('FG/IJ/ABCD': IsoDateStr); *
* *
* After the above executes, UsaResultStr contains: 02/29/1996 *
* ============================================================== *
dcl-pr GenUtl_FormatString varchar(40);
TemplateFormat varchar(40) const;
InputString varchar(26) const;
end-pr;

* ============================================================== *
* See corresponding prototype on using this service procedure. *
* ============================================================== *
dcl-proc GenUtl_FormatString;
dcl-pi *n varchar(40);
TemplateFormat varchar(40) const;
InputString varchar(26) const;
end-pi;
dcl-c TemplateChars 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
return %xlate(TemplateChars: InputString: TemplateFormat);
end-proc;

Sincerely,

Dave Clark

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.