Difference between revisions of "Is Generic Match"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) |
||
Line 1: | Line 1: | ||
[[Category:Sample Code]] | [[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 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. |
Revision as of 19:44, 13 December 2018
Contents
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.
Service Procedure
**free //============================================================================== // This procedure determines if a needle is found in a haystack--or not. The // haystack is represented by a long character string. Optionally, the // beginning character index position of the needle is also returned. //============================================================================== dcl-pr GenUtl_InString ind; pNeedle varchar(32767) const; pHayStack varchar(65535) const; pIndex packed(5:0) options(*nopass); end-pr; //============================================================================== // 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