Jump to content

This topic is 8009 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

How does one take names from individual records in a contact list and display them in one continuous sentence, a line-by-line stream with commas separating the names? BTW, I know how to join first and last names, etc.

Thanks in advance.

L.

Posted

You can create a script to loop through your found set of records to do this.

First, create a Global text field "g_Name_String". To ignore records with no names in them, the script is:

Freeze Window

SetField[g_Name_String,""]

Go To Record/Request/Page [First]

Loop

.If[not IsEmpty(YourNames)]

.. SetField[g_Name_String, g_Name_String & YourNames & ", "]

.End If

.Go To Record/Request/Page [Next][Exit After Last]

End Loop

# Trim off the last comma and space characters

SetField[g_Name_String, Left(g_Name_String,Length(g_Name_String)-2)]

This will produce a string in the global field like:

Russ Baker, Bill Clinton, Marylin Monroe

You can play around with the script if you don't want the space after the comma. Depending on the number of records and length of names, you may come up against Filemaker's 64,000 characters limit in a text field (but I doubt it).

Posted

Russ,

Great response! I look forward to trying this out.

A few questions:

1) Line 4 of your script begins with a Period (.), a space and then SetField(.... Are the period and space required?

2) A wild guess here: the concantenated field to merge first and last names would be referenced to "YourNames"?

3) Your examples are alphabetized. Do I add a Sort step to accomplish that?

Thanks for your prompt response.

L.

Posted

There is also a loop...end loop combination missing:

SetField[g_Name_String,""]

Sort [restore, no dialog]

Go To Record/Request/Page [First]

# Loop through all the found records.

Loop

If[not IsEmpty(YourNames)]

SetField[g_Name_String, g_Name_String & YourNames & ", "]

End If

Go To Record/Request/Page [Next][Exit After Last]

End Loop

# Trim off the last comma and space characters

SetField[g_Name_String,Left(g_Name_String,Length(g_Name_String)-2)]

-bd

Posted

1. No. I only do that to indent it in the forum so it sort of display like it will in FMP. In your script, FMP will automatically indent script steps inside If statements (and Loops).

2. I have assumed that the YourNames field is a calculated text field made up of your concatenated first and last names = FirstName & " " & LastName

3. Coincidence. The script will produce the text string in the order of the records - so if you want them alphabeticised, then you will need to sort them first. Otherwise, pot luck.

If you want to create a sort step in the script, put it at the start Sort[Restore, No dialog]. Then you will need to create the sort first in browse mode (by last name ascending, then first name ascending) and then edit the script and select replace when you are asked to keep/replace the sort order. Your sort will then be stored in the script.

Posted

Another method which doesn't require a script is to use the valuelistitems function. I've attached a file that demonstrates this technique.

I have it set up so that it displays the names as "FirstName LastName", but the list is sorted by Last Name then First Name.

List-o-Names.fp5.zip

Posted

Thanks to all for the prompt responses. I'm working with all your suggestions and if I need additional help I'll post a note here.

Cheers,

L.

This topic is 8009 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.