[Gambas-user] Wiki Observation, SQL syntax
Tobias Boege
taboege at ...626...
Fri Jan 2 14:25:59 CET 2015
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
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list