I want to capitalise 1st letter of every word in a field.
Specifically, I have a name field where parts of the name are separated by a space, or by a -(dash) for double barrelled names.
How can I change the 1st letter of every name, including the 2nd part of a double barrelled name, to upper case.
Is this possible in FPL?
Change 1st letter of every 'word' to upper case
Moderators: Jon, Steve, Ian, Dave
-
- Moderator
- Posts: 184
- Joined: Tue Sep 11, 2007 8:58 am
-
- Moderator
- Posts: 184
- Joined: Tue Sep 11, 2007 8:58 am
A function, say initcap, would be nice. But there is no such function in FPL, as yet.
In the meantime, the following code will do the job.
Need a numeric field called POS. The field to be converted is called NAME.
In the meantime, the following code will do the job.
Need a numeric field called POS. The field to be converted is called NAME.
Code: Select all
if [length(NAME) < 2]
set NAME = uppercase(NAME);
else
set NAME = uppercase(substring(NAME,1,1)) + lowercase(substring(NAME,2,length(NAME)-1));
set POS = 2;
loop [POS < length(NAME)]
if [substring(NAME,POS,1) = ' ' or substring(NAME,POS,1) = '-' ]
set POS = POS + 1;
set NAME = substring(NAME,1,POS - 1) + uppercase(substring(NAME,POS,1)) + substring(NAME,POS+1,length(NAME)-1);
endif
set POS = POS + 1;
endloop
endif
0 x
Who is online
Users browsing this forum: No registered users and 15 guests