[Gambas-user] Databowser-Buttons, How to "click" them by code ?

Benoît Minisini gambas at ...1...
Sat Jan 3 02:16:44 CET 2015


Le 30/12/2014 05:47, ub2 at ...36... a écrit :
> (My last mail got lost somewhere in another thread.
> I don't know why but try again.)
>
>
> Dear Gambas Cracks
>
>
> Sorry for this question. I'm sure the answer will be simple,
> but I'm searching for it since weeks...
> A short hint would be very appreciated.
>
>
> My question:
> Is there a way to "click" the Databowser-Buttons (Save, NewRec, GotoLast)
> by a script? Something like Databrowser.SaveRec or .NewRec or .ShowLast?
>
> My Situation:
> Migrating thousands of records from a csv into a Sql-DB I use a databrowser.
> On a form I have different buttons with scripts which:
> - repair/modify most common csv-syntax-errors and then
> - import each record into datacontrols connected to the databrowser/datasource
> - if everything is fine
> -- script then shall "click" save, show last record, open new record,
>      and then start next "record-migration-loop"
> -- if not, user needs to resolve "advanced errors" manually and then
> continue the "semi-auto-migration-script" again. This is also the reason why
> I do not work with an "invisible" 2-connection-2-result-comparison
> (as discussed in this mailing list some weeks ago).
>
>
> Thanks for Gambas,
> thanks for your support,
> and a good start into 2015 to all Gambas!
>
>
> Hubi
> ub2 at ...36...
>

What you want is not possible at the moment, but this is very easy to add.

If you can't use the development version, you can search the DataBrowser 
children recursively until you find the buttons you need (look at the 
DataBrowser source code to know their name).

Once you get a reference on a button, just set its Value to True to 
trigger it.

And note that you have a CsvFile class in the gb.util component in the 
development version that allows to browse a CsvFile line by line, taking 
into account the separator character, and the quoting character.

Regards,

-- 
Benoît Minisini




More information about the User mailing list