[Gambas-user] In search of two features
Rob
sourceforge-raindog2 at ...94...
Fri Mar 7 21:17:59 CET 2008
On Friday 07 March 2008 14:50, Kari Laine wrote:
> first I would like to see join command in Gambas. Command would
> join array elements or collection elements to a string.
It does, but it's a method of the array, not a stand-alone command.
mystring = myarray.Join(",") ' would result in comma-separated values
> second, some kind of indexing for text boxes. I am making a billing
> program and I have form with the following layout.
This is a very frequently-requested feature, but I doubt we'll ever
see it because populating an array at design time isn't really a
great programming practice.
The way my clients and I have done it is like so (pseudo-code from
memory, may not actually compile):
dim i as integer
dim o as object
dim products as new object[]
for i = 0 to 39
o = new Textbox(ME) as "products"
o.x = 10
o.y = 10 + (20 * i)
o.width = 100
o.height = 16
o.tag = i ' we store the array index in the tag
products.add(o)
next
Then you can receive events for your textboxes and handle them
appropriately:
sub products_LostFocus()
dim i as integer
dim o as object
o = last
i = o.tag
if o.text <> "" then
updatedatabase(i, o.text)
endif
end
where "sub updatedatabase(productname as string, id as integer)" is a
subroutine that would include something like mydb.exec("update
mytable set productname = &1 where id = &2", productname, id).
Rob
More information about the User
mailing list