[Gambas-user] "Best Practices"; Richard Terry and charlesg.

Doug Gack douggack at ...67...
Sun May 25 23:43:06 CEST 2008


All;

1. I wish I really understood how these "list thingies" worked, but I'll just plod on as best I can.

First, charlesg sent in an excellent example of using a keyrelease event form a text (search) box, and populating a pick list from there.  Works great.  (See his code, below, and/or his complete post of 19 May, 2008.)

My methods and perhaps requirements seemed to be a bit different, so I did it my way, but it's quick and efficient.  I loaded a table with 8,003 names in it, and the response is as fast as my old hands can type....

The conversion is still a work in progress, but the web side is available at: http://dgack.selfip.com/RollCall/ , and it includes the original documentation for the Access/ASP implementation, and for the current version.  I haven't packaged any of it, yet, but is anyone wants a copy, I'll be glad to forward it along.

If interested, please read the intro, as it fairly well explains the purpose of this tiny application.  There are hot links (in both versions of the documentation) to the forms in use, just click the link. 

The new implementation docs need a _lot_ of editing, but I'm working on it as time and enthusiasm permit.  Lots of the things I encountered lead to more questions, but I'm going to attempt to experiment and answer them myself.  I'll post success (or failure) as I get those tasks completed.  Note that there are four desktop forms, and three different approaches to doing a look-up.  At this point, I believe that there will always be multiple ways in use.

Second, I'm using MySql, and the MySql Administrator and Query Browser (Query Tool) in both Winders and Linux.  I started with Postgres, but in the final analysis, I think MySql is easier to come to terms with.  Too bad I still can't back up and restore Views and Procedures, but I work around that by saving the create code as text files, in case I need to restore them.

Third, I create two list boxes (or a combo box and a list box, as needed), where the first list box is visible, and the second one is not.  The name in the visible box corresponds to a primary key in the hidden box, so by manipulating the index(es), I can click on the name, and immediately retrieve the corresponding PK in the hidden one.  (I would have preferred to use a global array, but I can't, so this is a way to 'cheat').

~~~~~~~~~~~~~~~~~~~     charlesg's code:

As for the name search: I have not used your size datasets but have been
> amazed at the speed of the following. Typing text into a TextBox filters the
> displayed data in the ListBox. I guess it would be even quicker if you (in
> your case) searched from the start of each data record rather than using
> instr. A click of the ListBox can then transfer the complete data back to
> the TextBox.
> ------------------------------------------------
> PUBLIC SUB txtName_keyRelease()
>   DIM txtUpper AS String
>   DIM txtList AS String
>  
>   IF key.Code = key.Return OR key.Code = key.Enter OR key.Code = key.Tab
> THEN
>     'go nowhere if field is blank. This does not stop you tabbing out of an
> empty field
>     'so must still check for valid fields when  is clicked. 
>     IF IsNull(txtName.text) THEN
>       txtName.SetFocus
>     ELSE 'go to next field
>       txtDate.SetFocus
>     ENDIF
>   ELSE 'filter the listbox to allow entries containing the txtfield text.
>       IF Len(txtname.Text) = 0 THEN
>          ListFill 'subroutine to default fill with all the data
>       ELSE
>          txtUpper = UCase(txtName.Text)
>          lstSupplier.Clear
>          FOR EACH res
>             IF InStr(UCase(res!p_desc), txtUpper) <> 0 THEN
>                lstSupplier.Add(Format(res!p_box, "00") & ", " &
> Format(res!p_number, "0000") & ", " & res!p_desc & ", " & res!p_date & ", "
> & res!p_wherefrom)
>             ENDIF
>          NEXT
>       ENDIF         
>   ENDIF
> END

~~~~~~~~~~~~~~~~~~~~~~

For what it is worth, on 2.6, under Fedora and Ubuntu, the key.code stuff doesn't seem to work.??????



Doug Gack
Homepage: http://dgack.selfip.com

_________________________________________________________________
Give to a good cause with every e-mail. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?souce=EML_WL_ GoodCause



More information about the User mailing list