PRB: INDEX ON Expression Var Causes Error and Doesn't Evaluate

Last reviewed: July 26, 1995
Article ID: Q125656
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a

SYMPTOMS

After using macro substitution or a name expression to change an index filter in an INDEX ON command, you receive this error:

   Variable '<variable value>' not found.

CAUSE

FoxPro evaluates the macro substitution or a name expression as a variable name instead of a literal value. A variable used in an INDEX ON command as an Index Filter cannot be evaluated to its underlying value in the resulting index expression when you use macro substitution or a name expression.

STATUS

This behavior is by design. The variable used in the Index Filter must always be present before using that index. Note that macro substitution or name expression will function as expected to the left of the equal sign of the INDEX ON command.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create and run a program containing this code:

    USE customer cityn="Seattle" INDEX ON city TO test FOR city=cityn

    This program will create an .IDX file named test with an index on the field named city and an index filter of city=cityn.

  2. Use macro substitution or name expression to change the INDEX ON expression to this:

    INDEX ON city TO test FOR city=&cityn

    -or-

    INDEX ON city TO test FOR city=EVAL(cityn)

    You might hope the result would be an index filter of city="Seattle". But the following error message is generated:

    Variable 'Seattle' not found.


Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 2.60a
KBCategory: kbprg kbprb
KBSubcategory: FxprgMacrosub


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 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.