Subject Re: Change Upper Case
From Gaetano D. <gaetanodd@hotmail.com>
Date Sun, 2 May 2021 07:29:43 +1000
Newsgroups dbase.getting-started

On 2/05/2021 6:57, roy price wrote:
> Thanks for this information, I have successfully used both suggestions, which go a long way towards viewing the indexed field correctly in the Form, and changing the first character of the first word of the character field to upper case.
> However my major problem was with the second word of the character field, which sometimes is upper case and sometimes lower.
> A clue to the solution might be that there is a space before the word to be changed.
> (In Botany, the convention is for the (First letter) Species to be upper case, and the Variety in lower case.)
> Regards
> Roy price

You can use at() to find the position of the spaces and parse the field
value into words and form there you apply the required capitalization to
each word and rebuild the string with spaces and commas as required.
atcount() in dUFLP's stringEx.cc will allow you to count the spaces (and
hence the number of words, first trim() the leading and trailing spaces,
then 2 spaces = 3 words, but alos look for a comma used as separator
with no spaces...etc.). With those tools you can modify only the strings
that the expected number of words in the field and log the remaining
ones in a file to look at and determine the next set of rules to deal
with those ones.

As long as you can find a logic that covers a sufficient number of
records, you can write a simple function to normalize the contents of
that field, and reduce the amount that require manual correction to a
handful.

During data entry, you can use onKey() to trigger some normalization
actions, make some characters illegal (e.g. prevent tabs or hyphens to
be used if the standard is to use a comma, use the rowset's canSave
event to look for illegal characters...etc. If you can provide a sample
of the data you're working with (and has most of the abnormalities you
are trying to correct, I am happy to give it a try.

Gaetano.