Difference between revisions of "Strip Formatting"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) |
||
Line 5: | Line 5: | ||
The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to strip all specified formatting delimiters out of a character string. If the delimiters are omitted then, by default, only blanks are stripped—including embedded blanks. | The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to strip all specified formatting delimiters out of a character string. If the delimiters are omitted then, by default, only blanks are stripped—including embedded blanks. | ||
− | == Service | + | == Service Prototype == |
+ | Place the following in a separate copybook for inclusion in both the caller and the service program source members. | ||
<pre> | <pre> | ||
**free | **free | ||
Line 18: | Line 19: | ||
DelimsValue varchar(64) const options(*omit); | DelimsValue varchar(64) const options(*omit); | ||
end-pr; | end-pr; | ||
+ | </pre> | ||
+ | |||
+ | == Service Procedure == | ||
+ | Place the following in a service program source member. | ||
+ | <pre> | ||
+ | **free | ||
//============================================================================== | //============================================================================== |
Revision as of 16:22, 14 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Strip Formatting service procedure. This service procedure simply allows the caller to strip all specified formatting delimiters out of a character string. If the delimiters are omitted then, by default, only blanks are stripped—including embedded blanks.
Service Prototype
Place the following in a separate copybook for inclusion in both the caller and the service program source members.
**free //============================================================================== // Strip all occurrences of the specified delimiter(s) from a string -- // including embedded occurrences of those delimiters. If delimiters // are omitted, then all blanks are stripped by default. //============================================================================== dcl-pr GenUtl_StripFormatting varchar(512) rtnparm; StringValue varchar(512) const; DelimsValue varchar(64) const options(*omit); end-pr;
Service Procedure
Place the following in a service program source member.
**free //============================================================================== // Strip all occurrences of the specified delimiter(s) from a string -- // including embedded occurrences of those delimiters. If delimiters // are omitted, then all blanks are stripped by default. //============================================================================== dcl-proc GenUtl_StripFormatting export; dcl-pi *n varchar(512) rtnparm; StringValue varchar(512) const; DelimsValue varchar(64) const options(*omit); end-pi; dcl-s x packed(3:0); dcl-s OutputString like(StringValue); if %parms() < %parmnum(DelimsValue); // if omitted strip all blanks by default OutputString = GenUtl_ScanAndReplace(' ': %trim(StringValue): ''); else; OutputString = %trimr(StringValue); // else, strip only trailing blanks for x = 1 to %len(DelimsValue); // loop on formatting characters OutputString = GenUtl_ScanAndReplace( %subst(DelimsValue: x: 1) : OutputString: '' ); endfor; endif; return OutputString; // return result string to caller end-proc;
References
- GenUtl_ScanAndReplace service procedure