Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-07

[Fwd: Re: DisplayFormat property of dbgrid?]

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ivan Gan

Hi Howard,

you said:
"I wasn't able to tell that the DisplayFormat property of dbgrid did this documented anywhere?

And apparently, there is no EditFormat I want to
do is some rudimentary validation, e.g., make sure a zipcode is exacty five characters long and all characters are digits. How do I do that in a Lazarus/FPC dbgrid?"

you could use a try...except block to attempt to convert the number to an integer, this would tell if it is wrong, length could be achieved with length(inputstring) , it should also work with UTF-8 as numbers are a single byte subset of the UTF-8 encoding system, I wouldnt like to try it for text length on non latin text though
Why limit yourself to zip codes though, an application should have a more international appeal
A british postcode is like this B1 24NJ, CV21 3HB
If your using Zeos database components, specifically the table component, the field events onGetText & OnSetText could be a good place to do your checking

By having a mask field in the country table it should be possible to set the country first then match the postcode, this is the approach I am taking I have extensive lists in MySql on ZIP codes, countries, province/state, cities etc. which I have no objection to sharing
I am also working on an address book project
Basically it is being designed with Lazarus 0.9.25 beta for the UTF-8 support
Database is MySql using Zeos database components
The address lists are being built to show address information in dual language format, so China shows in English & Chinese, Israel in English & Hebrew
The real kicker though is in connecting it over the net to exchange non-personal address data with a central server
So if you enter the Hebrew translation for Tel-Aviv it will become available to all other users worldwide
I already have Chinese provinces in Chinese!
Thanks to US policy I have fairly complete lists on US postcodes & Cities but limited for other countries at the moment

I want to be able to print an envelope in 2 languages where appropriate & I want to do it when I can't even read the other language

I intend to also create a set of components to let others use this address book as a component within a project, for example accounts programs I would of course welcome any help with this project I personally dont intend to change from MySql as the database is already shared with web design code, having said that, I would welcome the ability to support differing database types within the application You can find the lists of countries at
http://comchatter.com/nlso/geodata.php, it is part of a much larger internationalization support project

Reply by email

Howard Lee Harkness
to Ivan Gan
Ivan Gan wrote 23 lines
Hi Howard, you said: > "I wasn't able to tell that the DisplayFormat property of dbgrid did > this documented anywhere? > > And apparently, there is no EditFormat I want to > do is some rudimentary validation, e.g., make sure a zipcode is exacty > five characters long and all characters are digits. How do I do that in > a Lazarus/FPC dbgrid?" > you could use a try...except block to attempt to convert the number to an integer, this would tell if it is wrong, length could be achieved with length(inputstring) , it should also work with UTF-8 as numbers are a single byte subset of the UTF-8 encoding system, I wouldnt like to try it for text length on non latin text though Why limit yourself to zip codes though, an application should have a more international appeal A british postcode is like this B1 24NJ, CV21 3HB If your using Zeos database components, specifically the table component, the field events onGetText & OnSetText could be a good place to do your checking

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.

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.

Show quoted text 6 lines
By having a mask field in the country table it should be possible to set the country first then match the postcode, this is the approach I am taking I have extensive lists in MySql on ZIP codes, countries, province/state, cities etc. which I have no objection to sharing

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.

Show quoted text 16 lines
I am also working on an address book project Basically it is being designed with Lazarus 0.9.25 beta for the UTF-8 support Database is MySql using Zeos database components The address lists are being built to show address information in dual language format, so China shows in English & Chinese, Israel in English & Hebrew The real kicker though is in connecting it over the net to exchange non-personal address data with a central server So if you enter the Hebrew translation for Tel-Aviv it will become available to all other users worldwide I already have Chinese provinces in Chinese! Thanks to US policy I have fairly complete lists on US postcodes & Cities but limited for other countries at the moment

Sounds like your project is substantially more ambitious than mine.

Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080719/504c17f5/attachment.html

Reply by email

Howard Lee Harkness
to Howard Lee Harkness

Just went looking for the Zeos components. Found a collection on SourceForge that was over 8 years old. I went to the Zeos forum, and found mention of a 'beta' that was nearly 2 years old. Is there a Zeos library that is actually current? If so, where do I find it?

Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080719/402f1a19/attachment.html

Reply by email

Luca Olivetti
to Howard Lee Harkness

En/na Howard Lee Harkness ha escrit:

Just went looking for the Zeos components. Found a collection on SourceForge that was over 8 years old. I went to the Zeos forum, and found mention of a 'beta' that was nearly 2 years old. Is there a Zeos library that is actually current? If so, where do I find it?

Mmh, the zeos web site isn't an example of usability... Just get the svn version
http://wiki.freepascal.org/Zeos_tutorial

But instead of installing the components you find in "zeosdbo_rework\packages\lazarus\" as the page says, just go to "trunk\packages\lazarus"
(I'd correct the page but since I'm doing this from memory I'm not exactly sure).
Oh, and if you update and rebuild lazarus, most probably the zeos components won't rebuild properly. You have to delete all object files (everything under "trunk\packages\lazarus\build") before rebuilding lazarus.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 Fax +34 93 5883007

Reply by email

Joost van der Sluis
to Howard Lee Harkness: I wanted to keep this as simple as possible, so I'm only considering US-style zipcodes.…

Op zaterdag 19-07-2008 om 15:54 uur [tijdzone -0600], schreef Howard Lee Harkness:

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.

You could use the TField.OnGetText and .OnSetText for that purpose. This is TDataset/TField functionality, and so is not available for ZEOS only.

Joost.

Reply by email