Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Errors in Form Code

Status
Not open for further replies.

fmoore0001

Programmer
Dec 3, 2002
192
US
Guys, I am looking for a practical way to find errors in forms AFTER I compile.

For example, I am upgrading a program where I had to change one screen type for searching to two different types. There were a number of form code references to this SEARCH1 one screen which I had to convert to SEARCHf21 and Searchf51. I got an error list and simply was going to forms and replacing, depending on the situation, the SEARCH1 with Searchf21 or Searchf51.

All went find except for one complex screen which still errors out with an error that it has an SEARCH1 reference I cannot seem to find!! Itself it is also based on several classes, though the classes are not giving a error when re-compiled. The error report after compile only states that I have the error, not where it is.

My question is this: It there another way to find this error in my form!
 
You may find it easier if you can see all of the code in the form at once by going to:

Tools-->Class Browser-->Choose-->Folder Icon (Open)-->Choose FORM for Files of Type-->Select Your Form-->Double Table Icon (View Class Code)

Brian
 
fmoore0001,

Are you saying that the compiler is reporting the error but not telling you which file it refers to? If so, you need Ted Roche and Barbara Peisch's WhichOne.Prg (see "Tracking down compilation errors" at
If the errors are occurring at run-time, hit the Suspend button (in the error dialogue) and open the debugger. The trace window will tell you which line of code you are on, and the watch window can be used to determined the file name.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
MikeLewis,

While the program you reference from your site is a neat little work-around, I don't think it is well suited in this case. It appears fmoore0001 already knows what screen is giving them the problems...

All went find except for one complex screen which still errors out with an error that it has an SEARCH1 reference I cannot seem to find

fmoore0001,

It can be a bugger sometimes to find every occurence of a particular string in a form (scx file) without a text search utility well suited to VFP. The scx files are little more than DBF files with the extension changed on them...they do in fact conform to the DBF structure perfectly and as such they can be opened and looked in just as you would open and look in a table (dbf). You may or may not have known this (I think you probably did) but I provide it to lend more information to this thread. Anyways, as such they can be searched and all occurences of a string can be found in them...once you know where the occurences are then you can proceed to go look in them and find out where the heck that dangling reference(s) is coming from. The following program I just wrote will go through a selected scx file and look in every row of every record and if it finds an occurence of the string you are looking for then it will log it into a cursor that you can browse at the end. The search is case insensitive but could easily be modified by changing ATC() to AT() to be sensitive to the case you enter. In any event, take the following code and paste it into a prg file and run it from within VFP and when prompted select that complex screen giving you the problems and enter SEARCH1 in the input dialog as the string you are trying to find.

Code:
LOCAL lcFile, lcStringToFind, lnTotalFields, lnFieldCount, lcCurrentField
lcFile = GETFILE('SCX',"Select the form you want to check:")
lcStringToFind = INPUTBOX("Enter what you are looking for:", "FIND WHAT?")
IF FILE(lcFile)
    IF !EMPTY(lcStringToFind)
        CREATE CURSOR crsOccurs (fieldname c(30), recnumber I)
        USE IN SELECT("MyForm")
        USE (lcFile) IN 0 AGAIN ALIAS "MyForm"
        SELECT "MyForm"
        = AFIELDS(aryFields,"MyForm")
        lnTotalFields = ALEN(aryfields,1)
        FOR lnFieldCount = 1 TO lnTotalFields
            lcCurrentField = aryFields(lnFieldCount,1)
            SCAN FOR ATC(lcStringToFind, TRANSFORM(EVALUATE(lcCurrentField))) > 0
                INSERT INTO crsOccurs (fieldname, recnumber) VALUES (lcCurrentField, RECNO("MyForm"))
            ENDSCAN
        ENDFOR
        IF RECCOUNT("crsOccurs") > 0
	        GO TOP IN "MyForm"
	        BROWSE NOWAIT
	        SELECT crsOccurs
            GO TOP IN "crsOccurs"
            BROWSE NOWAIT
        ELSE
        	USE IN SELECT("MyForm")
        	
            MESSAGEBOX([No Occurences of the string "] + lcStringToFind + [" were found.])
        ENDIF
    ENDIF
ENDIF

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top