--
Bill Todd (TeamB)
Use the FreeUDFLib for InterBase and it's "ProperCase" function.
--
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
I have a function that does this, i takes in a string and returns the string
in the 'Proper' form. The OnlyFirstWord boolean state whether you should
only change the first word or all words in teh string.
class function TAppUtils.CapitaliseString(str : String; OnlyFirstWord :
Boolean) : String;
var
i : integer;
begin
if str <> '' then begin
str := Lowercase(str);
str[1] := Uppercase(str[1])[1];
if Not OnlyFirstWord then begin
for i := 1 to Length(str) do begin
if (str[i] = ' ') and (Length(Str) > i+1) then
if Str[i+1] <> ' ' then
Str[i+1] := Uppercase(Str[i+1])[1]
end;
end;
end;
result := str;
end;
Hope this helps
Rudy
"Walter Abadi" <wab...@silaba.com> wrote in message
news:4330...@newsgroups.borland.com...
do it yourself. I would use
S := LowerCase(YourString);
if Length(S) > 0 then S[1] := Upper(S[1]);
works only for one-word strings.
> S[1] := Upper(S[1]);
my bad. it is UpCase
I might be nitpicking ... but ...
> I have a function that does this, i takes in a string and returns the
string
> in the 'Proper' form. The OnlyFirstWord boolean state whether you should
> only change the first word or all words in teh string.
>
> class function TAppUtils.CapitaliseString(str : String; OnlyFirstWord :
> Boolean) : String;
> var
> i : integer;
> begin
> if str <> '' then begin
> str := Lowercase(str);
> str[1] := Uppercase(str[1])[1];
What if the string is like '40 beetles got it wrong'
Or: '1) jason told me to do it'
> if Not OnlyFirstWord then begin
> for i := 1 to Length(str) do begin
> if (str[i] = ' ') and (Length(Str) > i+1) then
And the string is like:
'Not at all,but he said he would do it'
The "b" won't get capitalized.
> if Str[i+1] <> ' ' then
> Str[i+1] := Uppercase(Str[i+1])[1]
> end;
> end;
> end;
> result := str;
> end;
:-)
Regards,
Shane
"Martijn Tonies" <m.to...@upscene.removethis.nospam.com> wrote in message
news:43315466$1...@newsgroups.borland.com...
but cheers for the heads up... :-)
Rudy
"Martijn Tonies" <m.to...@upscene.removethis.nospam.com> wrote in message
news:43315466$1...@newsgroups.borland.com...
:-) so far it works for me...if i get a bug/prob then i will adapt, only did
it last week :)
"Walter Abadi" <wab...@silaba.com> wrote:
I don't know where you're posting from, but in Irish a valid name
would be Colm Uá hUigín and any uppercase function would produce an
error. Also, for Dutch names Johannes van der Poel - I've seen various
spellings of Dutch names where the "van's" and the "der's" sometimes
take a capital and sometimes don't. "De" is also difficult, sometimes
being Pierre de la Rue, or Pierre De La Rue, or Pierre Delarue.
When to capitalize is tricky. Also, be careful of accents which may
capitalise to "strange" characters if your machine character set is
not the application's one.
Paul...
--
plinehan __at__ yahoo __dot__ __com__
XP Pro, SP 2,
Oracle, 9.2.0.1.0 (Enterprise Ed.)
Interbase 6.0.1.0;
When asking database related questions, please give other posters
some clues, like operating system, version of db being used and DDL.
The exact text and/or number of error messages is useful (!= "it didn't work!").
Thanks.
Furthermore, as a courtesy to those who spend
time analysing and attempting to help, please
do not top post.