>CLEAR >PRIVATE loCies > >DO CreateCountryCursor && sample data from which to pull our countries > >* Fill the loCies Collection >loCies = CREATEOBJECT("collectionq") >SELECT crsCy >SCAN > loCies.ADD(CREATEOBJECT("Country", ALLTRIM(crsCy.country),; > ALLTRIM(crsCy.capital), crsCy.population)) >ENDSCAN > >USE IN SELECT("crsCy") && close it now that we're done > >* Query >loCies.QWhere = [U] &&actually something like [cName = "U"] >loCies.QInto = [crsCW] &&actually [CURSOR crsCW] - don´t want to parse >loCies.Select >BROWSE > >* record >DEFINE CLASS country AS CUSTOM > cName = "" > capital = "" > population = 0 > PROCEDURE INIT (tcName, tcCapital, tnPopulation) > WITH THIS > .cName = tcName > .capital = tcCapital > .population = tnPopulation > ENDWITH > ENDPROC >ENDDEFINE > >************************************ >* subclass - no direct class extension in VFP >************************************ >DEFINE CLASS collectionq AS COLLECTION >*query parameters as properties grouped by the Q-prefix > QSelect = "*" > QFrom = "" > QInto = "" > QWhere = "" > QGroupBy = "" > QOrderBy = "" > QSet = "" &¶meter for Update() > > PROCEDURE Select >* BEGIN I´m not going to implement this generalized > CREATE CURSOR (this.QInto) (country c(21), capital c(19)) > FOR EACH oCW IN this > IF oCW.cName = this.QWhere > INSERT INTO (this.QInto) (country, capital) VALUES (oCW.cName, oCW.capital) > ENDIF > ENDFOR >* END I´m not going to implement this generalized - you get the idea > ENDPROC > > PROCEDURE Insert &&synonymous for ADD() >*... > ENDPROC > > PROCEDURE Update &&synonymous for ADD() >*... > ENDPROC > > PROCEDURE Delete &&synonymous for REMOVE() >*... > ENDPROC >ENDDEFINE > >* data courtesy Craig Boyd >PROCEDURE CreateCountryCursor > CREATE CURSOR crsCy(country c(21), capital c(19), area I, population I) > INSERT INTO crsCy(country, capital, area, population) VALUES ("Australia", "Canberra", 7686850, 20090437) > INSERT INTO crsCy(country, capital, area, population) VALUES ("Austria", "Vienna", 83858, 8184691) > INSERT INTO crsCy(country, capital, area, population) VALUES ("United Kingdom", "London", 244820, 60441457) > INSERT INTO crsCy(country, capital, area, population) VALUES ("United States", "Washington, D.C.", 9629091, 295734134) > INSERT INTO crsCy(country, capital, area, population) VALUES ("Zimbabwe", "Harare", 390580, 12746990) >ENDPROC >