_BEAUTIFY

Files

This collection contains one item for each file in a project. It's part of the scheme added in VFP 6 for handling projects and their contents programmatically.

Usage

prjProject.Files.Method() prjProject.Files[ nIndex ].Method() uValue = prjProject.Files[ nIndex ].Property prjProject.Files[ nIndex ].Property = uValue
The Files collection gives you access to all the items in a project. It's an array in which each element is a File object. The collection has only one property of its own, Count, which tells how many files there are. There are a couple of methods that operate on the collection as a whole. Add adds a new file to the project. Item gives you access to an individual file. We can't see why you need Item—you can do the same thing simply by referencing Files[ nSomeItem ], but it's an OLE thing. Like Projects, Files is an ActiveX, rather than a native, collection. Most of the time, this isn't an issue, but it probably does have an effect on system resources. For sure, the error messages you get when you mess up on this stuff are OLE errors, not native VFP errors.

In the original release of VFP 7, the Files collection doesn't always get updated when it should. When you add a file other than a program (say, a form or menu), it doesn't show up in the Files collection, and Files.Count doesn't change for a while. Closing and reopening the project fixes the problem, but what a pain! Since this bug is likely to break a huge percentage of the project hooks out there, we're not surprised that it's fixed in SP1.


Example

* List all the files in the active project. FOR EACH oFile IN Application.ActiveProject.Files    ?oFile.Name ENDFOR

See Also

Add, Count Property, File, Item, Project


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net