First letter as a capital letter
- FlowHeater-Team
- Topic Author
- Offline
- Admin
Less
More
13 years 11 months ago #2081
by FlowHeater-Team
Best wishes
Robert Stark
First letter as a capital letter - Post(2081) was created by FlowHeater-Team
Translated submission in the German forum. You can read the original entry
here
.
Hi everybody,
Time and again users write everything in lower case for fields such as first or last names, street names and towns.
How can I ensure all initial letters are converted to upper case?
Thanks in advance.
Peter
Hi everybody,
Time and again users write everything in lower case for fields such as first or last names, street names and towns.
How can I ensure all initial letters are converted to upper case?
Thanks in advance.
Peter
Best wishes
Robert Stark
Please Log in or Create an account to join the conversation.
- FlowHeater-Team
- Topic Author
- Offline
- Admin
13 years 11 months ago #2082
by FlowHeater-Team
Best wishes
Robert Stark
Replied by FlowHeater-Team on topic Re:First letter as a capital letter - Post(2082)
Hello Peter,
You can do this by using five Heaters or with a single .NET Script Heater . I have prepared a brief example of both for you, see the enclosure. Note that this method would also normalize strings to "title case" if they were written all in upper case.
Using five Heaters you need 2x Substring , 1x ToLower , 1x ToUpper and 1x String Append . The pair of Substring Heaters first splits the incoming string on the first letter. Then the two parts are respectively transformed into upper case (the first letter) and lower case (the rest). The String Append Heater finally recombines the two transformed strings. If you need to repeat this for several fields, it can quickly become an arduous task. The script for the .NET Script Heater performs exactly the same thing with just one Heater. You simply need to copy the script below into the Heater (double click) and connect the input and output to the required fields.
You can do this by using five Heaters or with a single .NET Script Heater . I have prepared a brief example of both for you, see the enclosure. Note that this method would also normalize strings to "title case" if they were written all in upper case.
Using five Heaters you need 2x Substring , 1x ToLower , 1x ToUpper and 1x String Append . The pair of Substring Heaters first splits the incoming string on the first letter. Then the two parts are respectively transformed into upper case (the first letter) and lower case (the rest). The String Append Heater finally recombines the two transformed strings. If you need to repeat this for several fields, it can quickly become an arduous task. The script for the .NET Script Heater performs exactly the same thing with just one Heater. You simply need to copy the script below into the Heater (double click) and connect the input and output to the required fields.
Code:
public object DoWork()
{
object o = InValues[0].GetString();
if (o == null)
return o;
string s = (string)o;
if (s.Length == 0)
return s;
string s1 = String.Empty;
string s2 = String.Empty;
s1 = s.Substring(0, 1);
s2 = s.Substring(1);
s1 = s1.ToUpper();
s2 = s2.ToLower();
return s1 + s2;
}
Attachment toupper_tolower.zip not found
Best wishes
Robert Stark
Attachments:
Please Log in or Create an account to join the conversation.
Time to create page: 0.256 seconds