PRB: Unexpected Results from _FindVar() in FoxPro for MS-DOSID: Q122357 The information in this article applies to:
SYMPTOMSThe _FindVar() function, when used with FoxPro for MS-DOS, returns 1 (TRUE) when the variable passed to this function does not exist.
CAUSEAn invalid (negative) NTI value was passed to the _FindVar() function.
RESOLUTIONDo not pass negative NTI values to the _FindVar() function. The NTI value is passed to the _FindVar() function as the first parameter of that function. For a technique you can use to determine if a variable exists, please see the following article in the Microsoft Knowledge Base:
STATUSThis behavior is by design. The behavior of the _FindVar() function is undefined when negative values are passed to the function. The behavior of _FindVar() can only be predicted when valid NTI values are passed to the function.
MORE INFORMATION
FoxPro Code to Reproduce BehaviorCLEAR IF "Win"$VERS()
ELSE
ENDIF
SET ALTERNATE ON testvar = "Hello this is a test" ? "Test with a variable name that does exist ..." ? = qmark("testvar") ? ? "Test with a variable name that does not exist ..." ? = qmark("notexist") SET LIBRARY TO SET ALTERNATE TO CLOSE ALTERNATE
C Code to Reproduce Problem
{
}
FoxInfo myFoxInfo[] = { };
FoxTable _FoxTable = { };
ResultsThe following results are observed when this code is executed in FoxPro for Windows. These are the expected results: Test with a variable name that does exist ... The value returned by FindVar (where = 1) is: 0 The value returned by FindVar (where = -1) is: 1 The value returned by FindVar (where = 0) is: 1 Test with a variable name that does not exist ... The value returned by FindVar (where = 1) is: 0 The value returned by FindVar (where = -1) is: 0 The value returned by FindVar (where = 0) is: 0 The following results are observed when this code is executed in FoxPro for MS-DOS. The last two lines indicate the problem: Test with a variable name that does exist ... The value returned by FindVar (where = 1) is: 0 The value returned by FindVar (where = -1) is: 1 The value returned by FindVar (where = 0) is: 1 Test with a variable name that does not exist ... The value returned by FindVar (where = 1) is: 0 The value returned by FindVar (where = -1) is: 1 The value returned by FindVar (where = 0) is: 1 Additional reference words: 2.60a FoxDos KBCategory: kbprg kbprb KBSubcategory: |
|
Last Reviewed: January 5, 1995 © 1999 Microsoft Corporation. All rights reserved. Terms of Use. |