Difference between revisions of "In String"

From MidrangeWiki
Jump to: navigation, search
(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...")
 
(Summary)
Line 1: Line 1:
 
[[Category:Service Procedures]]
 
[[Category:Service Procedures]]
 
== 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 needle is found in a haystack--or not.  Optionally, the position of the needle in the haystack is also returned.  See also [[In List]] and [[Get List Entry]],  
+
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 needle is found in a haystack—or not.  Optionally, the position of the needle in the haystack is also returned.  See also [[In List]] and [[Get List Entry]],
  
 
== Service Procedure ==
 
== Service Procedure ==

Revision as of 21:42, 12 December 2018

Summary

The following are the RPG/LE fully free-form definitions and instructions needed for using the In String service procedure. This service procedure simply allows the caller to determine if a needle is found in a haystack—or not. Optionally, the position of the needle in the haystack is also returned. See also In List and Get List Entry,

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 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-proc GenUtl_InString     export;
  dcl-pi *n             ind;
    pNeedle             varchar(32767) const;
    pHayStack           varchar(65535) const;
    pIndex              packed(5:0)    options(*nopass);
  end-pi;

  dcl-s iPosn         packed(5:0);                                       

  iPosn = %scan(pNeedle: pHaystack);   // look for needle in haystack

  if %parms < %parmnum(pIndex)         // if optional parm not passed
  or %addr(pIndex) = *null;            // or optional parm was omitted
  else;                                // skip it, else
    pIndex = iPosn;                    // return position of needle in haystack
  endif;

  return (iPosn > *zero);              // indicate if found or not
end-proc;