well let’s start by showing you how to track those undeclared variables in a foxpro application, as we all know that we don’t have to declare a variable before use in this wonderful language, but it is good practice to do so.

so today i found the exact use of the ‘_vfp.languageoptions’ property so let me share what i found. well i new this existed since version 7 but never investigated its use till today.

i have a small application that is been developed in my spare time, this program is what i will use to locate the undeclared variables on.

so let’s start:

all this is done in the vfp command window

_vfp.languageoptions = 1
set debugout to c:\temp\undeclared.txt
do rebuild.exe
set debugout to

to let you know, i went through all the options in my application, making sure i opened all the forms within the app, and then clicked the exit button to return back to the vfp command window.

so i opened the undeclared.txt file and found the following:

langoptionserr,29/04/2005 11:18:03,122,clsinitoobject.getdata,procedure clsinitoobject.getdata initoobj.fxp,lainifile
langoptionserr,29/04/2005 11:18:03,168,clsinitoobject.getdata,procedure clsinitoobject.getdata initoobj.fxp,lcrealname
langoptionserr,29/04/2005 11:18:03,83,clsrebuild.setenvironment,procedure clsrebuild.setenvironment e:\development\vfp\reindex\rebuild.exe,ladirs
langoptionserr,29/04/2005 11:18:03,5,frmrebuild.addtolist,procedure frmrebuild.addtolist e:\development\vfp\reindex\source\forms\frmrebuild.sct,ladirs
langoptionserr,29/04/2005 11:18:07,8,frmprops.builddirectorylist,procedure frmprops.builddirectorylist e:\development\vfp\reindex\source\forms\frmprops.sct,ladirs
langoptionserr,29/04/2005 11:18:07,11,frmprops.builddirectorylist,procedure frmprops.builddirectorylist e:\development\vfp\reindex\source\forms\frmprops.sct,ladbc
langoptionserr,29/04/2005 11:18:07,12,frmprops.builddirectorylist,procedure frmprops.builddirectorylist e:\development\vfp\reindex\source\forms\frmprops.sct,ladbf
langoptionserr,29/04/2005 11:18:19,5,frmrebuild.addtolist,procedure frmrebuild.addtolist e:\development\vfp\reindex\source\forms\frmrebuild.sct,ladirs

so what does this mean i hear you cry well lets break down the columns:


specifies the name of the output type for searches and filters


specifies the time stamp when run (= datetime( ))


specifies the line number where error occurred (=lineno( ))


specifies the name of the procedure or method in which the error occurred ( = program( ))


specifies the name of the file in which the error occurred. (=sys(16( ))


specifies the name of the undeclared variable

so using this information, you can see that in the initoobj.prg in the class getdata method i have two variables that are not declared with a local or public. these are: lainifile and lcrealname
likewise you can see the other forms that have undeclared variables.
main reason behind these arrays are the fact they are created with the alines function, this creates the variables as private.

(taken from vfp help file)
declaring variables private does not create a variable (unlike declaring variables public or local).
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.


Leave a Reply

Your email address will not be published. Required fields are marked *