MONTH()

Item

This method behaves more like a property or collection. It belongs to the various ActiveX collections available beginning in VFP 6 and lets you grab an individual member of those collections.

Usage

oItem = Application.oCollection.Item( uIndex )
VFP has a number of ActiveX collections, including Projects, Files, Servers and so forth. These are array-like objects that contain references to multiple objects of the same type. Item is a way to get your hands on one member of a collection.

Inside VFP, it doesn't seem very important to have this method. It's easier to write _VFP.Projects[1] than _VFP.Projects.Item(1). However, we suspect that when you're driving VFP from another application, the first notation may not be available. In addition, we also suspect that, like the Count property of the collections, Item is a fairly standard method in the ActiveX world, so it's better for VFP's collections to have it than not. (In fact, we're pretty sure these collections are implemented using some standard classes, and that Count and Item have simply come along for the ride.) Bottom line—we don't see ourselves using the Item method in our VFP code.

As you'd expect, you can pass a numeric index to Item. That's no big deal. However, you can also pass the name of the item you want. That's cool! This eliminates the need to iterate through all members of a collection, looking for the one you want—instead, you just specify it by name. Even more cool is that this notation works even with the shortcut version. That is, you can use either _VFP.Projects.Item("Test.PJX") or just _VFP.Projects("Test.PJX"). In some of their VBA documentation, Microsoft explains this by saying that Item is the default method of collections.

Notice that when you're referring to a file (as with the Projects or Files collections), you need the whole file name, including the extension, but not the path.

One interesting note: Although Item is labeled a method with a single parameter, you can use square brackets instead of parens to pass the parameter. Makes us think that maybe Item is really just another collection.

Example

* One way to loop through the open project and display names FOR nCount = 1 TO _VFP.Projects.Count    ? _VFP.Projects.Item[nCount].Name ENDFOR   * Here's how we'd really do this FOR EACH oProject IN _VFP.Projects    ? oProject.Name ENDFOR

See Also

Count Property, Files, Projects, Servers


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