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.