Page 1 of 1

transform records into dbf

Posted: Sun Jan 15, 2017 2:23 pm
by Silvio.Falconi
I have a dbf with a field "etnombre"

Image



with capitalized record. Is there a function to convert all records in lower case? except of course the first letter which must remain in uppercase

Code: Select all

#include "Fivewin.ch"


Function Test()
cDesc:= ""
use soggetti alias so

GO TOP 

Do while ! so->(eof())
      

          cDesc :=  Stringlower( so->etnombre, " ")

replace so->etnombre with cDesc

so->(Dbskip())
Enddo
  xbrowse()
  return nil

//------------------------------------------------------//

STATIC  FUNCTION Stringlower( string, parser )
Local cStr:= "", nLenPar:= Len( parser )
Local commapos := 0

   If parser == NIL .OR. parser == "e"
     parser := " "
   EndIf

   Do While Len( string ) > 0
      commapos := at( parser, string )
      IF commapos > 0
         cStr+= Lower(Left( string, commapos - 1 )) + " "
         string := Lower(SubStr( string, commapos + Len( parser ) ))
     ELSE
         cStr+= string
         string := ''
     ENDIF
  ENDDO

RETURN( cStr )
 
But I hae all record on lower case as you can see on this picture

Image

I wish Have the first letter on uppercase

Re: transform records into dbf ( resolved)

Posted: Sun Jan 15, 2017 2:59 pm
by Silvio.Falconi
resolved

Code: Select all

 
#include "Fivewin.ch"


Function Test()
   cDesc:= ""
   cDesc2:= ""
   cFirst :=""
   cStringa := ""
use soggetti alias so

GO TOP 

Do while ! so->(eof())
      
   cDesc := so->etnombre
   nLen:=Len(cDesc)
   cFirst := Upper(Left(cDesc,1))

   cDesc2 :=  Right(Stringlower( cDesc, " "),nLen-1)


   cStringa:= cFirst+cDesc2

replace so->etnombre with cStringa

so->(Dbskip())
Enddo
  xbrowse()
  return nil

//------------------------------------------------------//

STATIC  FUNCTION Stringlower( string, parser )
Local cStr:= "", nLenPar:= Len( parser )
Local commapos := 0

   If parser == NIL .OR. parser == "e"
     parser := " "
   EndIf

   Do While Len( string ) > 0
      commapos := at( parser, string )
      IF commapos > 0
         cStr+= Lower(Left( string, commapos - 1 )) + " "
         string := Lower(SubStr( string, commapos + Len( parser ) ))
     ELSE
         cStr+= string
         string := ''
     ENDIF
  ENDDO

RETURN( cStr )


 

Re: transform records into dbf

Posted: Sun Jan 15, 2017 9:19 pm
by nageswaragunupudi
Same thing can be done with one line of program

Code: Select all

   GO TOP
   DBEVAL( { || FIELD->ETNOMBRE := TokenUpper( Lower( FIELD->ETNOMBRE ) ) } )
 

Re: transform records into dbf

Posted: Sun Jan 15, 2017 10:46 pm
by Marc Venken
nageswaragunupudi wrote:Same thing can be done with one line of program

Code: Select all

   GO TOP
   DBEVAL( { || FIELD->ETNOMBRE := TokenUpper( Lower( FIELD->ETNOMBRE ) ) } )
 
I've seen you using this kind of functions many time

DBEVAL()
AEVAL()

On the FW Wiki they are not listed
On Harbour I only see AEVAL()

TokenUpper() I'v also not found.

Where is the right location of finding ALL RECENT functions of FW?

Re: transform records into dbf

Posted: Sun Jan 15, 2017 10:58 pm
by nageswaragunupudi
All these functions are from (x)Harbour. Not FWH.
These functions have been there from the times of 16-bit Clipper days.

Re: transform records into dbf

Posted: Mon Jan 16, 2017 12:05 pm
by Silvio.Falconi
thanks I allready resolved

Re: transform records into dbf

Posted: Mon Jan 16, 2017 1:37 pm
by ADutheil
Marc Venken wrote:Where is the right location of finding ALL RECENT functions of FW?
Have a look at: https://harbour.github.io/doc/

Re: transform records into dbf

Posted: Mon Jan 16, 2017 11:02 pm
by Marc Venken
Ok. Thanks.