FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour upper/lower
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
upper/lower
Posted: Tue Jan 22, 2019 04:03 PM

exist a function to change the first letter Upper and the other lower of a string ?
sample I have ---> PALMA I wish ---> Palma

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: upper/lower
Posted: Tue Jan 22, 2019 04:38 PM
Silvio,

StrCapFirst( <cString> ) --> cCnvString

This function capitalize the first character and transform the other charaters to lowercase.

Sample:

local cString := "text TO CONVERT" cString := StrCapFirst( cString ) ? cString --> "Text to convert"

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: upper/lower
Posted: Tue Jan 22, 2019 07:26 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: upper/lower
Posted: Tue Jan 22, 2019 09:57 PM
Silvo

I wrote this function that automatically puts the very first letter as caps .. then searches for a space in the string then +1 capitalizes the next letter .. and so on thru the string.

Rick Lipkin



Code (fw): Select all Collapse
//------------------
Func _UpperLower( cText )

Local nLen,i,cField

nLen  := len( cText )

For i = 1 to Len(cText)

   If i = 1
      cField := upper(substr(cText,i,1))
      Loop
   Endif

   // check for multiple words
   // use space as the delimeter

   If substr(cText,i,1) = space(1) // found a space in between words
      i++
      cField := cField+" "+upper(substr(cText,i,1))
      loop
   Else
      cField := cField+lower(substr(cText,i,1))
   Endif

Next

cText := cField

Return(cText)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: upper/lower
Posted: Wed Jan 23, 2019 10:44 AM

thanks to all

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion