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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dat Environment

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
218
GB
Is ther any way to check to see if a forms data environment has any has code attached to it.

I have an app with numerous forms and occasionaly I find incorrect data environment in it.

Rather than opening each form and checking, I am lookin for some code to do it. It would probably be similar to the widely used code to "clear tage in report forms".

Sam
 
In principle, yes. Because each SCX is a DBF and you can USE and then of course navigate to anything including DE code faster than doing that manually in the IDE.

Nevertheless I wouldn't suggest writing anything.

Mainly you USE some.scx and locate the record with ObjName="Dataenvironment", then see into Methods Memo for code of the dataenvironment.

Bye, Olaf.
 
[tt]MODIFY PROJECT YourProject
FOR EACH oFile IN _VFP.ActiveProject.Files
IF oFile.Type = "K" && form
USE (m.oFile) ALIAS __Form
LOCATE FOR Class = dataenvironment
IF FOUND() AND NOT EMPTY(Methods)
* There's code in the DE. Do what you want.
ENDIF
USE IN SELECT("__FORM")
ENDIF
ENDFOR
[/tt]

Tamar
 
Tamar,

This is what I was looking for.

Tamar and Olaf,
Except I found the code in the method of an object named cursor1.
What would happen if there is a table in the DE window of the form, but no code. Where would the evidence of this show up in the .scx file?

I noticed that if I remove the table from the DE window, the object "Cursor1" is no longer in the .scx file.

Sam
 
Every table or view you put into the dataenvironment is in a cursor object. This is not to be confused with a cursor in a workarea, but its named that way, as it results in such a cursor.

See:
Indeed also these cursor objects can have code in them. Strictly speaking still that isn't code in the dataenvironment like click code in form buttons is no form code, but button code.

All tables and views in a DE will show up as such objects with class = "cursor", you could also have cursoradaptes in there. Anything in the DE will point to the Dataenvironment record via the Parent field, as the Parent field is empty for the dataenvironment itself you can find all such records via LOCATE FOR EVL(Parent,Objname) = "Dataenvironment"

All these objects in the DE can have no further child objects, but of course any code in there can create any further objects, if you want to find all classes and project files involved in the DEs of your forms yo would therefore also start parsing code and finding further references.

Bye, Olaf.
 
So this would find them all:
Code:
Modify Project ?
For Each oFile In _vfp.ActiveProject.Files
   If oFile.Type = "K" && form
      Use (m.oFile.Name) Alias __Form
      Locate For Evl(Parent,ObjName) = "Dataenvironment"
      Do While Found() 
         If Not Empty(Methods)
            * There's code in the DE. Do what you want.
            ? "Code found in", oFile.Name, Objname
         EndIf 
         Continue 
      EndDo
      Use In Select("__FORM")
   Endif
Endfor

Bye, Olaf.
 

Thanks guys,

The code and explantion were a great help. The code works fine with some minor modifications for what I needed.

Sam

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top