dbTalk Databases Forums  

Parsing a multiple work field

comp.databases.filemaker comp.databases.filemaker


Discuss Parsing a multiple work field in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bubba
 
Posts: n/a

Default Parsing a multiple work field - 08-22-2010 , 02:36 PM






I am trying to construct a Case statement to read a Company Name Field
(called NameField) which can contain from 1 to 4 words.

I want to determine how many words the field contatins and then get the
first 2 letters of each word.

I want to Put them together, i.e.,

Abbott Company International would be = Abcoin

and

Acme First Rate Products = Acfirapr.

What would the Case statement look like?

Appreciate any help, thanks

Reply With Quote
  #2  
Old   
Your Name
 
Posts: n/a

Default Re: Parsing a multiple work field - 08-22-2010 , 08:29 PM






In article <2010082212362526146-bubba@mailnet>, Bubba <bubba (AT) mail (DOT) net> wrote:

Quote:
I am trying to construct a Case statement to read a Company Name Field
(called NameField) which can contain from 1 to 4 words.

I want to determine how many words the field contatins and then get the
first 2 letters of each word.

I want to Put them together, i.e.,

Abbott Company International would be = Abcoin

and

Acme First Rate Products = Acfirapr.

What would the Case statement look like?

Appreciate any help, thanks
There's a few different approaches to this, but you don't need a Case
statement. Probably the easiest way is to use the Left function and the
Middle Words function - despite the name, it can be used for the first and
last word as well.

MiddleWords(text; starting*word; number*of*words)

You can extract the first two letters of any word using the Left function
around this Middle Words function. The first two letters of word number X
are obtained by:
Left(MiddleWords(NameField; X; 1); 2)

This means your entire calculation is simply a matter of concatenating
these letters together.
e.g.

AbbreviatedName Calculation, Text Result, Unstored
= Left(MiddleWords(NameField; 1; 1); 2)
& Left(MiddleWords(NameField; 2; 1); 2)
& Left(MiddleWords(NameField; 3; 1); 2)
& Left(MiddleWords(NameField; 4; 1); 2)

You don't need to worry about how many words there are. If there is no
third word, then the Middle Words function will return empty text, and the
Left function performed on empty text is more empty text.
e.g.
NameField = "The Smurfs"

Abbreviated Name = "Th" & "Sm" & "" & ""
= "ThSm"


Depending on what you're using this AbbreviatedName for, you may want /
need to add extra characters to the end to make sure there are always
eight. The easiest way to do this is to concatenate eight characters to
the end of the calculation above, and then extract just the first eight
from the entire text.
e.g.

AbbreviatedName8Chars Calculation, Text Result, Unstored
= Left(
Left(MiddleWords(NameField; 1; 1); 2)
& Left(MiddleWords(NameField; 2; 1); 2)
& Left(MiddleWords(NameField; 3; 1); 2)
& Left(MiddleWords(NameField; 4; 1); 2)
& "XXXXXXXX"
;8)


Helpfull Harry )

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.