On Sat, 10 Jan 2015, Lewis Balentine wrote: > On 01/10/2015 03:04 AM, Caveat wrote: > > On 10/01/15 09:52, Lewis Balentine wrote: > >> Result (gb.db) > >> This class represents the result of a SQL request. > >> This class is not creatable. > >> This class acts like a read / write array. > >> This class is *enumerable* with the FOR EACH keyword. > >> > >> Guess this should be obvious but not to me .... pray tell what > >> type/class does one use to enumerate it ?? > >> I tried "ResultField[]" > >> I tried "Collection" > >> I tried to try "record" > >> As a last resort I tried String[] > >> Suffice it to say: I have not a clue :-\ > >> > >> ======== > >> Dim MyResult as Result > >> Dim MyRecord as ????? > >> > >> Result = Connection.Find (Something) > >> > >> For Each MyRecord in MyResult > >> Print MyRecord["Field1Name"] > >> Print MyRecord["Field2Name"] > >> Print MyRecord["Field3Name"] > >> Next > >> ============ > >> regards, > >> > >> Lewis > > > > I presume you started here http://gambaswiki.org/wiki/comp/gb.db/result > > And then clicked on the big obvious link to FOR EACH, arriving here: > > http://gambaswiki.org/wiki/lang/foreach > > And then didn't look at the second example... :-P > > > > Kind regards, > > Caveat > > > > Thank thee ... :-) > I did follow that path and I did miss the nuance of the second example. >
Better yet, don't click on the "FOR EACH" link but on the "enumerable" link. This brings you to the Result-specific documentation for enumeration. You want to remember this because not every class is mentioned in the FOR EACH language documentation. As you see, Result has a different way of being enumerated. Instead of returning the objects in the result, a new iteration moves an internal cursor through the rows of the result data. This means, each execution of the loop body For Each hResult Print hResult!onefield Next will yield a different print (unless some rows contain the same value, of course). Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user