logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Position of Hyphen: msg#00560

Subject: Re: Position of Hyphen
Dan

You could do all this in one calculation, but I wouldn't suggest it! If it was me, I'd split it up:

cFirstName = Left(FullName; ((Position(FullName; " "; 1; 1)) - 1)) [text] cSecondName = Right(FullName; (Length(FullName) - Position(FullName; " "; 1; 1))) [text]

(you can't use LeftWords and RightWords, because they count a hyphen as a word break!)

Then....

cHyphenPosition = Position(cSecondName; "-"; 1; 1) [number]
cSecondNameLength = Length(cSecondName) [number]
cTextAfterHyphen = Right(FullName; (cSecondNameLength - cHyphenPosition)) [text] cInitials = Left(cFirstName; 1) & " " & (Left(cSecondName; 1)) & (If (cHyphenPosition ≠ 0; (Left(cTextAfterHyphen; 1)); "")) [text]

This works, I've tested it. But it does depend on someone having two and only two names.

Colm



<Prev in Thread] Current Thread [Next in Thread>