[Gambas-user] Miscellaneous routines for text box validation

Richard richard.j.walker at ...247...
Fri Feb 15 03:52:09 CET 2008


On Wednesday 13 February 2008 20:46:14 Richard wrote:
> On Friday 08 February 2008 03:39:07 richard terry wrote:
> > Hi all,
> >
> > My gambas learning project is progressing well (a contacts database
> > manager), and I've got the point I can create new
> > people/names/address(es), etc, now have to fine tune the gui, so not
> > wanting to re-invent the wheel, I wondered if anyone had in their
> > possession, or pointers to it, code which would do stuff like.
> >
> > for textboxes:
> >
> > Autocapitalise, or autocaps
> > Date validation routines/formatting routines
> > Name auto capitalisation eg for McBeth, or O'Neil etc
> >
> > Also In VB  in the textbox routines one had (index, keyascii) and one
> > could manipulate the keyascii value to whatever to either exclude keys or
> > autocapitalise things etc
> >
> > I wondered how this worked in gambas, as though I can detect the
> > keypress, I couldnt see a way to send back a changed key value to the
> > textbox.
> >
> > Thanks in anticipation.
> >
> >
> > Richard
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> Hi Richard,
> I did some name and address processing for a data capture post-processing
> program at work last year which involved processing UK postcodes and Mc,
> Mac and O' surnames. The problem I had to solve for the surnames was to
> present them in a uniform format as specified by the customer.
>
> I had to be able to take whatever style the operator had used and convert
> it to whatever the customer expected. The method I chose was to convert all
> name fields to title case and then search for the "Mc", "Mac" and "O'"
> patterns so I could capitalise the next letter.
>
> That was usually all I needed to do for "Mc" and "O'" as these are quite
> unique patterns at the beginning of names. The case for "Mac" was
> complicated by the possibility of a word not being a Scottish name; Macey,
> Mackie and Macclesfield spring to mind. I handled these using a lookup list
> in an array. The list should contain all words you don't want to convert,
> like those three and maybe a dozen others.
>
> In Gambas there is no title case function for a string. Just parse out the
> words using your own white space character list to determine the word
> breaks and then set the first character of each word to upper case. Now you
> have me interested in it again I think I'll try a Gambas translation.
>
> Richard
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

Richard,
I have attached a simple Gambas project which demonstrates the method I used 
for forcing initial capital letters in names.

It uses a a slightly modified version of the TitleCase() function I sent to 
you to enable smart handling of names like O'Donnell, MacDonald, Mackintosh 
and McVeigh. It also makes a fair job of abbreviations (Mrs, Dr, MP) and any 
it misses are quite easy to add to the relevant look up word list. Names like 
Du Plessis and place names like Southend-On-Sea should work too.

You may also want to add any two or three letter words which might be found in 
Oz that I haven't included.

It is fairly well tested, but I may have introduced unexpected "features" as 
the code is completely different from my original VB implementation of the 
same concepts. If you have any problems just shout out and I'll either fix it 
or just commiserate with you :~)

Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TitleTest-1.0.tar.gz
Type: application/x-tgz
Size: 11853 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20080215/2e9c3d48/attachment.bin>


More information about the User mailing list