2 Replies Latest reply on Apr 10, 2014 6:46 AM by ryyno10

# Finding mid-paragraph space " " position

### Title

Finding mid-paragraph space " " position

### Post

hello,

I'm stuck trying to find a way to find the precise position of the median space in a paragraph so I can substitute a carriage return.  I used the following let function:

My vars:

\$\$mpl_body = paragraph texted depending upon list position as indicated by \$i

Let (
[
paraghString = Trim ( GetValue ( \$\$mpl_body ; \$i ) );
\$breakSpacePositionLast = Position ( paraghString ; " " ; Length ( paraghString ) ; -1 );
\$breakSpacePositionMiddle = ?
];
Replace ( paraghString ; \$breakSpacePositionMiddle; 0 ; "¶" )
)

I'm using \$breakSpacePositionLast to find the last space; i though this could be used in some manner to find the space closest to the middle of the paragraph.

Can anyone provide some direction?

• ###### 1. Re: Finding mid-paragraph space " " position

If any of these functions are unfamiliar, you can look them up in FileMaker Help.

Try this approach:

Let (
[
paraghString = Trim ( GetValue ( \$\$mpl_body ; \$i ) );
SpaceList = Substitute ( paraghString ; " " ; ¶ ) ;
medSpace = Div ( ValueCount ( SpaceList ) ; 2 ) ;
First = LeftValues ( SpaceList ; medSpace ) ;
Second = RightValues ( SpaceList ; ValueCount ( SpaceList ) - medSpace )
] ;

Substitute ( Left ( First ; Length ( First ) - 1 ) & "XXXXX" & Left  ( Second ; Length ( Second ) - 1 ) ; [ ¶ ; " " ] ; ["XXXXXX" ; ¶ ] )
) // Let

Note: RightValues and LeftValues append a ¶ to the end of the text they return. I'm using the Left and Length functions to remove these unwanted characters inside the Substitute function.

• ###### 2. Re: Finding mid-paragraph space " " position

Thanks Phil, i guess i should've been thinking array...