Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an abbreviate formula?

Status
Not open for further replies.

lkerr

Technical User
Mar 2, 2005
162
US
I am wondering, is there a formula that will automatically create an abbreviation based on the first letter of each word in a phrase? i.e. would create NYNY for New York New York?

I am using CR9 ... this is just a curiosity question, not a life or death thing ...

LK
 
You could use something like the following:

left(split({@string}," ")[1],1) +
(if ubound(split({@string}," ")) > 1 then
left(split({@string}," ")[2],1)) +
(if ubound(split({@string}," ")) > 2 then
left(split({@string}," ")[3],1)) +
(if ubound(split({@string}," ")) > 3 then
left(split({@string}," ")[4],1))

...where you added enough clauses to reflect the maximum number of components to the string. Or you could use a loop:

numbervar i;
stringvar abbrev;

for i := 1 to len({@string}) do(
if i = 1 then abbrev := {@string}[1] else
if {@string} = " " then
abbrev := abbrev + {@string}[i + 1] else
abbrev := abbrev);
abbrev

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top