<div dir="ltr">On Sat, Jul 19, 2008 at 8:22 AM, Ivan Gan <<a href="mailto:ivan@comchatter.com">ivan@comchatter.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Howard,<br>
<div><br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">you said:<br>
"I wasn't able to tell that the DisplayFormat property of dbgrid did<br>
anything at all. Is this documented anywhere?<br><br>
And apparently, there is no EditFormat property at all. What I want to<br>
do is some rudimentary validation, e.g., make sure a zipcode is exacty<br>
five characters long and all characters are digits. How do I do that in<br>
a Lazarus/FPC dbgrid?" <br></blockquote>
</div></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
</div>you could use a try...except block to attempt to convert the number to<br>
an integer, this would tell if it is wrong, length could be achieved<br>
with length(inputstring) , it should also work with UTF-8 as numbers are<br>
a single byte subset of the UTF-8 encoding system, I wouldnt like to try<br>
it for text length on non latin text though<br>
Why limit yourself to zip codes though, an application should have a<br>
more international appeal<br>
A british postcode is like this B1 24NJ, CV21 3HB<br>
If your using Zeos database components, specifically the table<br>
component, the field events onGetText & OnSetText could be a good place<br>
to do your checking</blockquote><div><br>I wanted to keep this as simple as possible, so I'm only considering US-style zipcodes. This is for an attorney's client contact database, so it will only have current Texas residents.<br>
<br>I'm not using the Zeos components, although I've seen them recommended here. I've got the zipcode maintenance screen working -- maybe even good enough -- with about 8 lines of my own code, using PostgreSQL and sqldb components. The UI is a bit funky (for instance, clicking on 'edit' in the dbNavigator doesn't cause the field in the dbGrid to get the focus), and I would like to fix some of the aggravation, but it does allow me to do everything that has to be done.<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
By having a mask field in the country table it should be possible to set<br>
the country first then match the postcode, this is the approach I am taking<br>
I have extensive lists in MySql on ZIP codes, countries, province/state,<br>
cities etc. which I have no objection to sharing</blockquote><div>Well, as I thought I had mentioned, there does not appear to be any
masking available in the dbGrid component. I suppose I need to look at
Zeos, assuming Zeos will work with PostgreSQL. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I am also working on an address book project<br>
Basically it is being designed with Lazarus 0.9.25 beta for the UTF-8<br>
support<br>
Database is MySql using Zeos database components<br>
The address lists are being built to show address information in dual<br>
language format, so China shows in English & Chinese, Israel in English<br>
& Hebrew<br>
The real kicker though is in connecting it over the net to exchange<br>
non-personal address data with a central server<br>
So if you enter the Hebrew translation for Tel-Aviv it will become<br>
available to all other users worldwide<br>
I already have Chinese provinces in Chinese!<br>
Thanks to US policy I have fairly complete lists on US postcodes &<br>
Cities but limited for other countries at the moment<br>
</blockquote>Sounds like your project is substantially more ambitious than mine.<br></div>-- <br>Howard Lee Harkness<br>
</div>