McCormick Posted August 21, 2003 Posted August 21, 2003 Does anyone know an effective way to turn a text field into intials? Just the first letter of each word; names, for instance. I'm sure I could cobble together something clumsy with PatternCount and Left, but if anyone has an elegant solution, I would be delighted to hear it.
McCormick Posted August 21, 2003 Author Posted August 21, 2003 Okay, for the record, this is what I am using now - it only works ona hard-coded maximum number of words (in this cae 4) so it's not teribly flexible or pretty. I guess I could just keep adding new "paragraphs" for each new word I want it to accomodate, but I'd still love to know if anyone has anything simpler: Left(LeftWords(Employee Name, 1), 1) & If(PatternCount( Employee Name, " ") > 1, Left( MiddleWords( Employee Name, 2, 1), 1) , "") & If(PatternCount( Employee Name, " ") > 2, Left( MiddleWords( Employee Name, 3, 1), 1) , "") & If(PatternCount( Employee Name, " ") > 0, Left( RightWords( Employee Name, 1), 1) , "")
CobaltSky Posted August 22, 2003 Posted August 22, 2003 Hello McCormick, There are certainly a few options that would be a little less onerous than what you are doing at present. If you would prefer to use a calculation then there is no way (at least with present versions of FM - and without using a plug-in) to make it open ended - you will have to code for a defined maximum number of words in the field. However you could do so with a somewhat more efficient calculation systax along the lines of: Left(MiddleWords(TextField, 1, 1), 1) & Left(MiddleWords(TextField, 2, 1), 1) & Left(MiddleWords(TextField, 3, 1), 1) & Left(MiddleWords(TextField, 4, 1), 1) & Left(MiddleWords(TextField, 5, 1), 1) & Left(MiddleWords(TextField, 6, 1), 1) & Left(MiddleWords(TextField, 7, 1), 1) & Left(MiddleWords(TextField, 8, 1), 1) & Left(MiddleWords(TextField, 9, 1), 1) & Left(MiddleWords(TextField, 10, 1), 1) & Left(MiddleWords(TextField, 11, 1), 1) & Left(MiddleWords(TextField, 12, 1), 1) & Left(MiddleWords(TextField, 13, 1), 1) & Left(MiddleWords(TextField, 14, 1), 1) & Left(MiddleWords(TextField, 15, 1), 1) & Left(MiddleWords(TextField, 16, 1), 1) & Left(MiddleWords(TextField, 17, 1), 1) & Left(MiddleWords(TextField, 18, 1), 1) & Left(MiddleWords(TextField, 19, 1), 1) & Left(MiddleWords(TextField, 20, 1), 1) etc... If you want to provide for the possibility that the field wioll contain hundreds or even thousands of words - and therefore you really need an open ended solution, I'd recommend that you consider setting the initials field with a script - such as the following example: Set Field [ gCounter, 0 ] Set Field [ Initials, "" ] Loop Set Field [ gCounter, gCounter + 1 ] Set Field [ Initials, Initials & Left(MiddleWords(TextField, gCounter, 1), 1) ] Exit Loop If [ gCounter = WordCount(TextField) ] End Loop where gCounter is a global number field. Such a script will deal with an unlimited number of words in the TextField field (well, up to FileMaker's 64k limit, at any rate). But it will have to be triggered by the user, unless you happen have access to one of the various plug-ins that can trigger a script automatically whenever a particular field is edited (in which case it could be made to operate in a way that would be functionally equivalent to a calculation field).
McCormick Posted August 22, 2003 Author Posted August 22, 2003 Yes, that seems to cover it. I think I'll just use the calc field for ten or so, it don't want to go all the way to a script. I knew there must be something smoother. Thanks!
Recommended Posts
This topic is 7866 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now