Funcion para Capitalizar textos - | function to be able to capitalize texts - Forum

Forum Navigation
You need to log in to create posts and topics.

Funcion para Capitalizar textos - | function to be able to capitalize texts

SPAIN

Alguien por casualidad conoce alguna funcion que permita capitalizar textos...

ejemplo  si en una entrada  una persona escribe    "alejandro valenti" que al guardarse se transforme en " Alejandro Valenti" y asi quede guardada...

No puedo darme cuenta como hacelo, ya que solo permite establecer propiedad a la entrada como Mayuscula o Minuscula pero no Capitalizada...

Si alguien tiene alguna idea de como lograrlo desde ya eternamente agradecido


ENGLISH

Someone by chance knows some function that allows to capitalize texts ...

For example, if in an entry a person writes "alejandro valenti" that when saved it becomes "Alejandro Valenti" and so it is saved

I can't figure out how to do it, since it only allows setting property to input as Uppercase or Lowercase but not Capitalized ...

If anyone has any idea of how to achieve it, forever grateful

{NeoBook Function}
Version=5,80
Language=VBScript
Comment=Capitalizar String
Param=%1|Text|String a Capitalizar
Param=%2|Variable|Variable para texto Capitalizado
{End}
Option Explicit

Dim a : a = Split("%1")

Dim i
For i = 0 To UBound(a)
a(i) = UCase(Left(a(i), 1)) & LCase(Mid(a(i), 2))
Next

publication.nbSetVar "%2", Join(a)

@joferar333

some function that allows to capitalize texts

Say the uncaptialized text is in [inputText] ... try this ...

Edited later because the Forum software had combined multiple spaces into just one

SetVar "[myText]" "[inputText]"
... optional; to remove multiple spaces
... 7 spaces to 1
StrReplace "[myText]" "       " " " "[myText]" ""
... 6 spaces to 1
StrReplace "[myText]" "      " " " "[myText]" ""
... 5 spaces to 1
StrReplace "[myText]" "     " " " "[myText]" ""
... 4 spaces to 1
StrReplace "[myText]" "    " " " "[myText]" ""
... 3 spaces to 1
StrReplace "[myText]" "   " " " "[myText]" ""
... 2 spaces to 1
StrReplace "[myText]" "  " " " "[myText]" ""

... now, split into an array of words
StrParse "[myText]" " " "[myWordArray]" "[myWordsCount]"

SetVar "[myCapText]" ""
... for each word in array
Loop "1" "[myWordsCount]" "[thisWordNumber]"
   SetVar "[thisWord]" "[myWordArray[thisWordNumber]]"
   StrLen "[thisWord]" "[thisWordLen]"
   ... capitalize first letter
   SubStr "[thisWord]" "1" "1" "[firstCharacter]"
   StrUpper "[firstCharacter]" "[firstCharacter]"
   ... remainging characters
   SubStr "[thisWord]" "2" "[thisWordLen]-1" "[remainingCharacters]"

   ... rejoin with rest of word
   SetVar "[capWord]" " [firstCharacter][remainingCharacters]"

   ... add to other words
   SetVar "[myCapText]" "[myCapText][capWord]"
EndLoop
... remove leading space
StrDel "[myCapText]" "1" "1" "[myCapText]"

... show result
AlertBox "myCapText" "***[myCapText]***"

 

proforma.guyot has reacted to this post.
proforma.guyot