Returns a number that represents the position of a string within another string.

Syntax

AT(<search expC>, <target expC> [, <nth occurrence expN>])

<search expC>

The string you want to search for in <target expC>.

<target expC>

The string in which to search for <search expC>.

<nth occurrence expN>

Which occurrence of the string to find. By default, dBASE Plus searches for the first occurrence. You can search for other occurrences by specifying the number, which must be greater than zero.

Description

AT(†) returns the numeric position where a search string begins in a target string. AT(†) searches one character at a time from left to right, beginning to end, from the first character to the last character. The search is case-sensitive. Use UPPER(†) or LOWER(†) to make the search case-insensitive.

You can specify which occurrence of the search string to find by specifying a number for <nth occurrence expN>. If you omit this argument, AT(†) returns the starting position of the first occurrence of the search string.

AT(†) returns 0 when

The search string isnít found.

The search string or target string is empty.

The search string is longer than the target string.

The <nth occurrence expN> occurrence doesn't exist.

When AT(†) counts characters in a memo field, it counts two characters for each carriage-return and linefeed combination (CR/LF) in the memo field.

Use RAT(†) to find the starting position of <search expC>, searching from right to left, end to beginning. Use the substring operator ($) to learn if one string exists within another.

The indexOf(†) method is similar to the AT(†) function, but in addition to the syntactic difference of being a method instead of a function and the fact that the position is zero-based, the methodís optional parameter specifies where to start searching instead of the nth occurrence to find.