This application object property provides ability to control general Visual FoxPro language settings. This includes the ability to check for improperly declared memory variables.
_VFP.LanguageOptions [= eValue] |
Return Value
- eValue
-
Bit Value Description 1
Strict type declaration is required for memory variables.
Remarks
Applies To: Application Object | _VFP System Variable
When LanguageOptions is set to 1, you must declare all memory variables and arrays as LOCAL or PUBLIC prior to using them. An attempt to use an undeclared variable or array will generate output to the DEBUG OUTPUT window. No error is generated. You can log this output to a file as in the following code:
В | Copy Code |
---|---|
SET DEBUGOUT TO MyErrorFile |
The output from undeclared variables in LanguageOptions is comma-delimited in the following format:
LangOptionsErr, DateTime, cLineNo, cProcedure|cMethod, cFileName, cVarName
Item | Description |
---|---|
LangOptionsErr |
Specifies the name of the output type for searches and filters |
DateTime |
Specifies the time stamp when run (= DATETIME(В )) |
cLineNo |
Specifies the line number where error occurred (=LINENO(В )) |
cProcedure|cMethod |
Specifies the name of the procedure or method in which the error occurred ( = PROGRAM(В )) |
cFileName |
Specifies the name of the file in which the error occurred. (=SYS(16(В )) |
cVarName |
Specifies the name of the undeclared variable |
Declaring variables PRIVATE does not create a variable (unlike declaring variables PUBLIC or LOCAL), so the following code generates a log entry:
В | Copy Code |
---|---|
PRIVATE myvar myvar = 1 |
Commands that create variables on the fly, such as SCATTERВ ...В NAME, REPORTВ ...В NAME and others, will generate log entries, because these variables are created as PRIVATE.
Example
The following code shows the debug output resulting from entering an undeclared variable, myvar.
В | Copy Code |
---|---|
_VFP.LanguageOptions=1 myvar=4 |
Strict typing in Visual FoxPro is enforced only at run time, so you must run code to detect errors. Strict typing affects both development and run-time versions of Visual FoxPro.
Note: |
---|
Use of private variables such as those declared with the PRIVATE command or those created using the NAME clause of certain commands will generate errors. If you are distributing code that might be affected by developers potentially setting this property to 1, you should protect your code by resetting this property to 0 when needed. |