Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Example

  dcl Source char value(' Our PL/I wields the Power ');
  dcl Pos fixed bin(31);

/* Find occurrences of any of the characters 'P','o',or 'w' in source *  /

  Pos = search (Source, 'Pow');              /*  returns 6 for the 'P'    */
  Pos = search (Source, 'Pow', Pos+1);    /*  returns 11 for the 'w'   */
  Pos = search (Source, 'Pow', Pos+1);    /*  returns 22 for the 'P'   */
  Pos = search (Source, 'Pow', Pos+1);    /*  returns 23 for the 'o'   */
  Pos = search (Source, 'Pow', Pos+1);    /*  returns 24 for the 'w'   */

  Pos = index (source, 'Pow',1);             /*  returns 22 for the 'Pow' */

In the above example, SEARCH returns the position at which any of the three characters ('P', 'o', or 'w') appear. INDEX returns the position at which the whole string 'Pow' appears.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)