Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PROPER() function
Message
De
26/02/2002 12:37:50
 
 
À
26/02/2002 10:12:53
Scott Starkey
Tindall Record Storage
Fort Worth, Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00625082
Message ID:
00625263
Vues:
10
Scott,

I've been using the function below for a long while. It doesn't have the power of a C++ DLL, but have nothing to complain about it <s>

After doing the selective upper/lower case loop you have the option to add some custom conversions to it (the StrTrans at the function end - note that those StrTrans are to convert some of the portuguese words, and need to be changed to your own words).
 Function xProper           &&  Extended Proper() Fox Function
*-------- -------
 LParameters pSourceStr
 Private     cSourceStr, nSourceLen, cObjectStr, bMustUpper, I, cChar, cIns

 If Empty (pSourceStr)
    Return ""
 endif

 cSourceStr =      pSourceStr
 nSourceLen = Len (pSourceStr)
 cObjectStr = ""
 bMustUpper = .T.

 For I = 1 to nSourceLen
     cChar = Substr (cSourceStr, I, 1)
     cIns  = cChar

     If ! Empty (cChar)
        If IsAlpha (cChar)
           If bMustUpper
              cIns = Upper (cIns)
           else
              cIns = Lower (cIns)
           endif
           bMustUpper = .F.
        else
           bMustUpper = .T.
        endif
     else
        bMustUpper = .T.
     endif

     cObjectStr = cObjectStr + cIns

 EndFor

 cObjectStr = cObjectStr + Space (1)

 cObjectStr = StrTran (cObjectStr, " Da " , " da " )
 cObjectStr = StrTran (cObjectStr, " Do " , " do " )
 cObjectStr = StrTran (cObjectStr, " De " , " de " )

 cObjectStr = StrTran (cObjectStr, " Das ", " das ")
 cObjectStr = StrTran (cObjectStr, " Dos ", " dos ")

 cObjectStr = StrTran (cObjectStr, " A "  , " a "  )
 cObjectStr = StrTran (cObjectStr, " O "  , " o "  )
 cObjectStr = StrTran (cObjectStr, " As " , " as " )
 cObjectStr = StrTran (cObjectStr, " Os " , " os " )
 cObjectStr = StrTran (cObjectStr, " E "  , " e "  )
 cObjectStr = StrTran (cObjectStr, " É "  , " é "  )
 cObjectStr = StrTran (cObjectStr, " Em " , " em " )
 cObjectStr = StrTran (cObjectStr, " Na " , " na " )
 cObjectStr = StrTran (cObjectStr, " No " , " no " )

 Return  Left (cObjectStr, nSourceLen)

 EndFunc              &&  Of xProper
Hope it helps,

Fernando
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform