Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Type

Every item in a project has some native type, like form, menu, FREE TABLE, and so forth. The Type Property indicates that type.

Usage

cTypeChar = filFile.Type

Each type is indicated by a single character. Some of them make intuitive sense, like “Q” for query or “R” for report. Others are a bit of a stretch, like “D” for FREE TABLE (that is, “DBF”) and “V” for class library (“VCX”) and a few make no sense at all: “K” for form? Maybe it stands for “sKreen”? Or maybe it’s “Kouldn’t find a letter we weren’t already using?”

You can find the complete list in the Help file.

Type is read-write! You can change the type of a file. VFP seems amazingly immune to weird values in the Type field. We were able to change the type of a program from "P" to "D" and then call the Modify method without trashing the project or crashing VFP. Not only that, but the appropriate editing window opened up. It does make you wonder what the point of the Type field is, though. It also means you need to be pretty careful about code like the example, since Type may not accurately identify the file type. Our view is that changing this property is a really bad idea. Just because they let you doesn't mean you have to do it.

Example

* Use Type to figure out whether or how you want to process
* each file in a project. Here we'll open forms and programs,
* and ignore everything else.
oProj = _VFP.ActiveProject
FOR EACH oFile IN oProj
   IF oFile.Type $ "PK"  && Program or Form
      oFile.Modify()
   ENDIF
ENDFOR

See Also

File, Project