Le 02/01/2015 14:25, Tobias Boege a écrit : > On Fri, 02 Jan 2015, Lewis Balentine wrote: >> I also note from an example in the "obsolete" Gambas Wiki that an >> explanation mark "!" is used to delimit field names in a result. >> http://gambasdoc.org/help/comp/gb.db/connection/edit?v3 >> >> I do not find any similar example in the current Gambas Wiki but perhaps >> I missed it. >> > > And about this: the ! operator is an array accessor. You know that Gambas > classes can implement the array operator [], so that e.g. > > myObject["stringkey"] = vValue ' or > myObject[fFloatKey] = vValue ' or any other datatype as index! > > can be written where myObject is an object of myClass which I wrote by > myself in Gambas. The special methods[0] _get() and _put() do that. > > Now, the ! operator is a special case applicable to string keys. object!key > is defined to be object["key"] where the key behind the ! is put as-is > inside quotation marks and used as a key. So you would use it if you already > know the (fixed) key, as for databases: > > rResult["surname"] ' can also be > rResult!surname > > but > > cCollection[sArgument] ' can NOT be, obviously, > cCollection!sArgument > > In any case, it is important to know that ! is a special case of []. > Sometimes you have fixed keys which contain parts that have special meaning > in Gambas, like in the Graphviz project in the software farm (yes, I'm > trying to increase its number of downloads :-)). There is a line > > Graphviz.VertexStyle["/"].Color = "red" > > which obviously cannot be written as > > Graphviz.VertexStyle!/.Color = "red" > > so we have to fall back to the [] notation, but a line like > > Graphviz.VertexStyle["test"].Color = "red" > > could become > > Graphviz.VertexStyle!test.Color = "red" > > Alas, I can't quote the wiki here because I haven't found any explicit > mention of !. I know through experimentation that it works this way (but > perhaps, I missed it, too). > > Regards, > Tobi > > [0] http://gambaswiki.org/wiki/cat/special >
Maybe it is not documented. That syntax comes directly from Visual Basic, and is there for easing the transition. -- Benoît Minisini ------------------------------------------------------------------------------ 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