Character '!'
Posted
#1
(In Topic #2024)
Trainee

Usage of character '!'
Hello, I come back to the Gambas programming after a few years,I don't remember exactly what the character '!' is used for (i know it's a special character)
for example :
$dev1 = $ResultConsult!arrLabels_h[0]
doesn't seem to work…
Normally i would write something like
$dev1 = $ResultConsult!lignes
with the name of the column, and it works fine,
but i want to use a chosen array.
Can you refresh my memory please ?
Thank you a lot
Posted
Administrator



As far as I am aware:
rResult!MyColumnName is valid (Column name = Fieldname of the record)
rResult!MyColumnName[0] is not
I do not know what you want to achieve, but you can loop the content of one field for all records.
Below an example to read the content of one field for all records into an array, presuming $rResult already holds the data and one of the field is named MyColumnName and holds string data.
This will result in an array containing the content of all records with filedname MyColumnName.
If you want to read it into a GridView or TableView, you use the Data event of said GridView or Tableview.
I hope this helps..
Last edit: by gbWilly
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Enthusiast


Or you can also write it like this:
Code
Public Sub Main()
Dim aText As String[] = ["Pippo", "Pluto", "Topolino"]
Print aText!"1" ' ---< Pluto
End
Posted
Administrator



The question was on a database result set to my understanding and not an array.Gianluigi said
Or you can also write it like this:
From “Post #13,871”, January 22nd 2026, 5:20 PM
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Expert


gbWilly said
The question was on a database result set to my understanding and not an array.Gianluigi said
Or you can also write it like this:
From “Post #13,871”, January 22nd 2026, 5:20 PM
From “Post #13,872”, January 22nd 2026, 5:23 PM
That raises an interesting point - What is a Result?
I know how it works with a database SELECT but not exactly what it is.
The documentations says: "This class acts like a read / write array."
At face value, it acts very much like a variant array even to the point that it is zero based..
These are the three methods I know of to identified data returned in a Result
If you have a data table with 'Id' as the first column name of the record.
Code
Result!Id
Result[0]
Result["Id"]
Will all return the value stored in 'Id'
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast


Reading this:gbWilly said
The question was on a database result set to my understanding and not an array.![]()
Instead, I understood that he wanted to know how to use the exclamation mark with an array.Zyfriala said
i want to use a chosen array.
I think Gambas uses a collection, but I'm not sure.Quincunxian said
That raises an interesting point - What is a Result?
Posted
Trainee

asking AI (Simplexity) i had this (one) explanation
" The operator ! expects a fixed identifier (a literal name like Result!Name), not a dynamic variable. "
so an array cannot be used.
But i'm pretty sure i solved this problem many years ago…i just don't remember how
Anyway, i wrote a little more code and stayed with
Result!ColumnName
If i ever find the solution i will post it here.
Many thanks
NB : i will open a new post because i have a problem with my gridview…
Posted
Administrator



I was thinking the same because of rResult["FieldName"] being possible, but I should look under the hood in source code to be sureGianluigi said
I think Gambas uses a collection, but I'm not sure.Quincunxian said
That raises an interesting point - What is a Result?
From “Post #13,877”, January 23rd 2026, 7:58 AM
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Trainee

i was looking in your examples, I did some tests and found it…
i don't have to write this, with the name of the column
$dev1 = ResultConsult_h!lignes
i just have to write this
$dev1 = ResultConsult_h[0]
and i'm not even obliged to use $dev1, i can write in my gridview using
my function directly with
fo_GridView_Write(row,column, ResultConsult_h[0])
I just save a lot of code…
thanks for your help
1 guest and 0 members have just viewed this.

