12 Replies Latest reply on Apr 4, 2016 9:21 AM by VanRan

# Calculation  (or script) To locate UpperCase Letter(s)

### Title

Calculation  (or script) To locate UpperCase Letter(s)

### Post

I need a calc which would substitute Each capital letter in a Word with a space then that character...

So:

"ThisIsFourWords" would result in:

"This Is Four Words"

If neccessary, this could become a script... but either way, I'm stymied.

My brain goes to analysing each letter against ASCII numbers, but even then can't come up with a solution that would be both complex and tedious.

• ###### 1. Re: Calculation  (or script) To locate UpperCase Letter(s)

Here is a script that will do what you ask.

•           Set Variable [ \$L; Value:Length ( test::TheText ) ]
•
•           Set Variable [ \$C; Value:1 ]
•
•           Set Variable [ \$NewText; Value:"" ]
•
•           Loop
•
•           Set Variable [ \$tL; Value:Middle(test::TheText;\$C;1) ]
•
•           If [ Code(\$tL)>64 and Code(\$tL)<91 ]
•
•           Set Variable [ \$NewText; Value:\$NewText & " " & \$tL ]
•
•           Else
•
•           Set Variable [ \$NewText; Value:\$NewText & \$tL ]
•
•           End If
•
•           Set Variable [ \$C; Value:\$C+1 ]
•
•           Exit Loop If [ \$C>\$L ]
•
•           End Loop
•
•           Set Field [ test::Converted; Trim(\$NewText) ]
• ###### 2. Re: Calculation  (or script) To locate UpperCase Letter(s)
If yourTextField contains not more than 80 chars, you could try this calculation:

TrimAll ( Char ( Substitute ( Code ( yourTextField )
; [ "00065" ; "0006500032" ]
; [ "00066" ; "0006600032" ]
; [ "00067" ; "0006700032" ]
; [ "00068" ; "0006800032" ]
; [ "00069" ; "0006900032" ]
; [ "00070" ; "0007000032" ]
; [ "00071" ; "0007100032" ]
; [ "00072" ; "0007200032" ]
; [ "00073" ; "0007300032" ]
; [ "00074" ; "0007400032" ]
; [ "00075" ; "0007500032" ]
; [ "00076" ; "0007600032" ]
; [ "00077" ; "0007700032" ]
; [ "00078" ; "0007800032" ]
; [ "00079" ; "0007900032" ]
; [ "00080" ; "0008000032" ]
; [ "00081" ; "0008100032" ]
; [ "00082" ; "0008200032" ]
; [ "00083" ; "0008300032" ]
; [ "00084" ; "0008400032" ]
; [ "00085" ; "0008500032" ]
; [ "00086" ; "0008600032" ]
; [ "00087" ; "0008700032" ]
; [ "00088" ; "0008800032" ]
; [ "00089" ; "0008900032" ]
; [ "00090" ; "0009000032" ]
) ) ; 1 ; 1 )

If it could contain more chars, then it will be better to create a recursive custom function, something like:

/*

*/

Let([

Character = Left ( text ; 1 ) ;

Space = If ( Length ( Filter ( Character ; "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) ) ; " " )

];

If ( Length ( text ) ; Space & Character & AddSpaceBeforeUpper ( Right ( text ; Length ( text ) - 1 ) ) )

)

to be trimmed in the calculation:

TrimAll ( AddSpaceBeforeUpper ( YourTextField ) ; 1 ; 1 )

Try it with YourTextField containing:

MyBrainGoesToAnalysingEachLetterAgainstAsciiNumbers,ButEvenThenCan'tComeUpWithASolutionThatWouldBeBothComplexAndTedious.
• ###### 3. Re: Calculation  (or script) To locate UpperCase Letter(s)

I tried the custom function that you suggest and it works great. I do not know if it would be possible that the acronyms can be incluided in that fuction. For instance:

CultureCellsCC it should be separated as Culture Cells CC

• ###### 4. Re: Calculation  (or script) To locate UpperCase Letter(s)

this is a nice piece of logic.   well done.

• ###### 5. Re: Calculation  (or script) To locate UpperCase Letter(s)

This what I did when I had the same problem.

Substitute ( \$WorkName ;// Name without spaces

["A" ; " A"];  ["B" ; " B"];  ["C" ; " C"];  ["D" ; " D"];  ["E" ; " E"];  ["F" ; " F"];  ["G" ; " G"];  ["H" ; " H"];  ["I" ; " I"];  ["J" ; " J"];  ["K" ; " K"];  ["L" ; " L"];  ["M" ; " M"];  ["N" ; " N"];  ["O" ; " O"];  ["P" ; " P"];  ["Q" ; " Q"];  ["R" ; " R"];  ["S" ; " S"];  ["T" ; " T"];  ["U" ; " U"];  ["V" ; " V"];  ["W" ; " W"];  ["X" ; " X"];  ["Y" ; " Y"];  ["Z" ; " Z"]

)

• ###### 6. Re: Calculation  (or script) To locate UpperCase Letter(s)

Are there only alphabets in the text?

//AddSpaceBeforeCapital ( text ; pos )

//This use 2 parametes, 2nd should be 1 at start.

Case ( pos > Length ( text ) ; text ;

Let ( [

p = pos ;

c = Middle ( text ; p ; 1 ) ;

pre = Middle ( text ; p - 1 ; 1 )

] ;

Case ( Exact ( c ; Lower ( c ) ) or Exact ( pre ; Upper ( pre ) ) ; AddSpaceBeforeCapital ( text ; p + 1 ) ;

AddSpaceBeforeCapital ( Replace ( text ; p ; 0 ; " " ) ; p + 2 )

)

)

)

I forgot how to find first capital letter in text...

• ###### 7. Re: Calculation  (or script) To locate UpperCase Letter(s)

If yourTextField contains not more than 80 chars, you could try this calculation:

• ###### 8. Re: Calculation  (or script) To locate UpperCase Letter(s)

Code() function returns number, so limited to 400digit.

• ###### 9. Re: Calculation  (or script) To locate UpperCase Letter(s)

great solution

• ###### 10. Re: Calculation  (or script) To locate UpperCase Letter(s)

Great concept - looks adaptable to other situations.

• ###### 11. Re: Calculation  (or script) To locate UpperCase Letter(s)

Just can't beat this for simplicity.

• ###### 12. Re: Calculation  (or script) To locate UpperCase Letter(s)

Thank you so much, it was very helpfull! It works!!!!