Difference between revisions of "Is Generic Match"
From MidrangeWiki
DaveLClarkI (talk | contribs) (→Service Procedure) |
DaveLClarkI (talk | contribs) (→Service Prototype) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
== 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 string—or not. | 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. | ||
+ | |||
+ | By [[User:DaveLClarkI|Dave Clark]] | ||
== Service Prototype == | == Service Prototype == | ||
Line 11: | Line 13: | ||
//============================================================================== | //============================================================================== | ||
− | // 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> | </pre> | ||
Line 27: | Line 30: | ||
**free | **free | ||
ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ||
− | DatFmt(*ISO) TimFmt(*ISO | + | 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