View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
Collections, Arrays & Iteration Mike Feltman F1 Technologies
Agenda Collections in VFP Working with Collections Writing Better Code with Collections Using Collections for Object Manipulation Adding Power to VFP Arrays Collections vs. Arrays Merging Arrays & Collections
Who Am I President F1 Technologies since 1990 Co-author Visual FoxExpress Consultant Xbase Developer since dBase III/FoxBase 1987
“Objects” Collections in VFP _SCREEN, _VFP, FormSet, DataEnvironment, Toolbar, Container, PageFrame, Page, Grid, Column, CommandGroup, OptionGroup, Container, Custom, Control
Other Collections in VFP _VFP Forms Projects Project Files Servers XMLAdapter Tables XMLTable Fields
The Collection Class New in VFP 8 Key Properties Count KeySort (0-3) Key Methods Add(eItem, cKey, eBefore, eAfter) Item(eIndex) GetKey(eIndex)
Iterating Collections FOR lnI = 1 TO loCollection.Count FOR EACH loObject in loCollection FOR EACH loObject in loCollection FOXOBJECT Examples: Iterate1.prg, Iterate2.prg, Iterate3.prg
UI Support for Collections Listbox ComboBox Example: CollectionDemo.SCX
Writing Better Code with Collections Problem: This.Parent.Page2.txtCompany creates a tightly coupled dependency. Solution: Dynamically retrieved Object references eliminate tight coupling. o=o(…) or o=f(…)
Using Collections for Multiple Object Manipulations AC CC WC
Returning an Array From within a class method a member array can be used as the return value. A function can return an array by calling a class method that returns an array. Example: aConcact in utility.prg
Wrapping an Array in a Collection Fox Data Objects – ADO / LINQ like DataCollection.prg, cDataCollection of cData
Conclusion Collections in VFP provide convenient ways to access objects Retrieving object references from collections can make code a lot more flexible and stable VFP has a lot of powerful options available on arrays Collection and array implementations are just different enough that each has their own place.