Using Dollar Sign ($) Function in FoxBASE+ or FoxPro

Last reviewed: July 5, 1995
Article ID: Q88891
The information in this article applies to:
  • Microsoft FoxBASE+ for MS-DOS, versions 1.21 and 2.1
  • Microsoft FoxBASE+ for the Macintosh, versions 1.21 and 2.1
  • Microsoft FoxPro for MS-DOS, versions 1.0, 1.01, 1.02, 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

The dollar sign ($) function searches for a string contained in another string. The correct syntax of the command is as follows:

   LOCATE FOR 'BOB'$UPPER(NAME)

This example locates a record that contains the string "BOB" anywhere in the NAME field.

The $ function can operate on a character field, a string memory variable, or a memo field. If the character expression is found, the function returns true (.T.). If the character expression is not found, the function returns false (.F.).

NOTE: This function does not work in a Memo field in Foxbase+ for the Macintosh.

Here's another example showing how to use the $ function:

   ?'OKAY'$memvar

This example returns the value true if "memvar" contains the string "OKAY" and false if "memvar" does not contain the string.

NOTE: The $ function cannot be optimized with Rushmore in FoxPro versions 2.0 and later. To search for a character expression in an indexed field, issue the SET EXACT OFF command. Use the SEEK function for optimum speed.


Additional reference words: FoxWin FoxDos 2.50 2.50a 1.21 2.10 1.00 1.01
1.02 2.00 1.21 2.10 1.x 2.x
KBCategory: kbprg
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 5, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.