#120552 - 2004-06-03 03:14 PM
How to print with an initial capital
|
Gos
Fresh Scripter
Registered: 2004-05-28
Posts: 23
|
I need a string to have inital capitals.
For those who do not understand my problem, this is what I need:
I need this string: "blautkak marsipan" to be written like this: "Blautkak Marsipan". The string is variable, so I can not write it manually.
-Gos-
|
|
Top
|
|
|
|
#120555 - 2004-06-03 03:47 PM
Re: How to print with an initial capital
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I'd do Ucase(left(...)) + Lcase(substr(...))
|
|
Top
|
|
|
|
#120556 - 2004-06-03 03:50 PM
Re: How to print with an initial capital
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Give this a try...
Code:
Break On fnProper("hello chris")
Function fnProper($String) If Not VarType($String) = 8 Exit 1 EndIf $String = Split($String) Dim $Array[Ubound($String)], $Index For Each $String in $String $Array[$Index] = Ucase(Left($String,1)) + Right($String,Len($String)-1) $Index = $Index + 1 Next $fnProper = Join($Array) EndFunction
|
|
Top
|
|
|
|
#120558 - 2004-06-03 04:28 PM
Re: How to print with an initial capital
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I kinda like this one, as a "proper" Proper function will convert the first character or a word to uppercase and all other characters in the word to lowercase.
Code:
fnProper("hElLo ChRiS")
Function fnProper($String) $String = Split($String) For $i = 0 to Ubound($String) $String[$i] = UCase(Left($String[$i],1)) + LCase(SubStr($String[$i],2)) Next $fnProper = Join($String) EndFunction
|
|
Top
|
|
|
|
#120560 - 2004-06-03 04:47 PM
Re: How to print with an initial capital
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Dang, I meant to dim that var, but forgot.
I've used it in Excel to correct capitalization for proper names. It has its uses.
|
|
Top
|
|
|
|
#120561 - 2004-06-04 08:58 AM
Re: How to print with an initial capital
|
Gos
Fresh Scripter
Registered: 2004-05-28
Posts: 23
|
Thank you guys. Your examples works. =)
-Gos-
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1046 anonymous users online.
|
|
|