$Index

From m204wiki
Revision as of 13:19, 20 April 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

$INDEX compares two character strings and returns a number equal to the first position within the first string at which the second string appears.

Example 1

$INDEX ('OTHER', 'THE') equals 2 $INDEX ('SAME', 'SAME') equals 1

Example 2

If the second string is not contained in the first or is a null string, zero is returned:

$INDEX ('SAME', 'OTHER') equals 0 $INDEX ('SOME', 'SOMEMORE') equals 0 $INDEX ('ABC', ") equals 0

Example 3

This request uses $INDEX to separate the last name from a field containing a full name in the form "last name, first name":

BEGIN FIND.RECS: FIND ALL RECORDS FOR WHICH DATE OF BIRTH IS LESS THAN 19660000 END FIND FOR EACH RECORD IN FIND.RECS %LASTNAME = - $SUBSTR (FULLNAME, 1, - $INDEX (FULLNAME,',')-1) ADD LAST NAME = %LASTNAME . . .