Difference between revisions of "Is Generic Match"
From MidrangeWiki
DaveLClarkI (talk | contribs) (Created page with "Category:Service Procedures == Summary == The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This se...") |
DaveLClarkI (talk | contribs) (→Service Prototype) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Sample Code]] | ||
[[Category:Service Procedures]] | [[Category:Service Procedures]] | ||
+ | __FORCETOC__ | ||
== 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 determine if a character string is a generic or partial match for another character | + | 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 determine if a character string is a generic or partial match for another character string—or not. |
− | == Service | + | By [[User:DaveLClarkI|Dave Clark]] |
+ | |||
+ | == 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 | ||
//============================================================================== | //============================================================================== | ||
− | // This procedure | + | // This procedure provides a Boolean result indicating whether or not the |
− | // | + | // first parameter is a generic (or partial) match of a second parameter. |
− | // | + | // Note that both kinds of matches are supported -- generic or partial -- |
+ | // by comparing the first part of the second parameter based on the | ||
+ | // length of the first parameter (after stripping any trailing asterisk). | ||
//============================================================================== | //============================================================================== | ||
− | dcl-pr | + | dcl-pr GenUtl_isGenericMatch ind; |
− | pNeedle varchar( | + | pNeedle varchar(50) const options(*trim); |
− | pHayStack varchar( | + | pHayStack varchar(50) const options(*trim); |
− | |||
end-pr; | end-pr; | ||
+ | </pre> | ||
+ | == Service Procedure == | ||
+ | Place the following in a service program source member. | ||
+ | <pre> | ||
+ | **free | ||
+ | ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ||
+ | DatFmt(*ISO) TimFmt(*ISO); | ||
//============================================================================== | //============================================================================== |
Latest revision as of 20:39, 21 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Is Generic Match service procedure. This service procedure simply allows the caller to determine if a character string is a generic or partial match for another character string—or not.
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 //============================================================================== // This procedure provides a Boolean result indicating whether or not the // first parameter is a generic (or partial) match of a second parameter. // Note that both kinds of matches are supported -- generic or partial -- // by comparing the first part of the second parameter based on the // length of the first parameter (after stripping any trailing asterisk). //============================================================================== dcl-pr GenUtl_isGenericMatch ind; pNeedle varchar(50) const options(*trim); pHayStack varchar(50) const options(*trim); 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); //============================================================================== // This procedure provides a Boolean result indicating whether or not the // first parameter is a generic (or partial) match of a second parameter. // Note that both kinds of matches are supported -- generic or partial -- // by comparing the first part of the second parameter based on the // length of the first parameter (after stripping any trailing asterisk). //============================================================================== dcl-proc GenUtl_isGenericMatch export; dcl-pi *n ind; pNeedle varchar(50) const options(*trim); pHayStack varchar(50) const options(*trim); end-pi; dcl-s iNeedle like(pNeedle); if GenUtl_SuffixString(pNeedle:1) = '*'; // if generic indicator present iNeedle = %subst(pNeedle: 1: %len(pNeedle)-1); // strip it off else; // else iNeedle = pNeedle; // take the string as-is endif; if %len(iNeedle) > %len(pHayStack); // if needle bigger than haystack return *off; // then a compare is not possible endif; return (iNeedle = %subst(pHayStack:1:%len(iNeedle))); // return result end-proc;
References
- GenUtl_SuffixString service procedure