Difference between revisions of "Add List Delimiter"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) (→Summary) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
== Summary == | == Summary == | ||
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 conditionally add a delimiter string to another (or "master") character string when the master character string has a length greater than zero (meaning: it already has content in it). | 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 conditionally add a delimiter string to another (or "master") character string when the master character string has a length greater than zero (meaning: it already has content in it). | ||
+ | |||
+ | By [[User:DaveLClarkI|Dave Clark]] | ||
== Service Prototype == | == Service Prototype == | ||
Line 26: | Line 28: | ||
Place the following in a service program source member. | Place the following in a service program source member. | ||
<pre> | <pre> | ||
+ | **free | ||
+ | ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ||
+ | DatFmt(*ISO) TimFmt(*ISO); | ||
+ | |||
//============================================================================== | //============================================================================== | ||
// If the supplied variable-length string (or list) has a length greater than | // If the supplied variable-length string (or list) has a length greater than |
Latest revision as of 15:54, 17 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Add List Delimiter service procedure. This service procedure simply allows the caller to conditionally add a delimiter string to another (or "master") character string when the master character string has a length greater than zero (meaning: it already has content in it).
By Dave Clark
Service Prototype
Place the following in a separate copybook for inclusion in both the caller and the service program source members.
**free //============================================================================== // If the supplied variable-length string (or list) has a length greater than // zero, then this procedure adds the supplied delimiter to the end of that // string on return. Otherwise, the string is returned unchanged. // This can also be used, for example, for dynamically building command (or SQL) // character strings that have conditional content without having to know // whether the built string already has content--or not. //============================================================================== dcl-pr GenUtl_AddListDelimiter varchar(65530) rtnparm; pList varchar(65530) const; pDelimiter varchar(30) const; end-pr;
Service Procedure
Place the following in a service program source member.
**free ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) DatFmt(*ISO) TimFmt(*ISO); //============================================================================== // If the supplied variable-length string (or list) has a length greater than // zero, then this procedure adds the supplied delimiter to the end of that // string on return. Otherwise, the string is returned unchanged. // This can also be used, for example, for dynamically building command (or SQL) // character strings that have conditional content without having to know // whether the built string already has content--or not. //============================================================================== dcl-proc GenUtl_AddListDelimiter export; dcl-pi *n varchar(65530) rtnparm; pList varchar(65530) const; pDelimiter varchar(30) const; end-pi; if %len(pList) <= *zero; // if list is empty return pList; // return unchanged list endif; return (pList + pDelimiter); // return resulting list end-proc;