Convert FileMaker value lists to AppleScript expression

Passing values between FileMaker and AppleScript can be a pain. Sure, you can use a named field and table in FileMaker to do this, but if you (or someone else) ever changes either of the names your AppleScript routine breaks. So, even though its not the most efficient way to do things, for short routines I often prefer to use FIleMaker’s ability to run a “Calculated AppleScript” (i.e., compile and run a script from a calculated text).

Other than efficiency, one problem with this approach is that you need to convert data into an AppleScript expression. This custom function makes it a simple task to pass a values list from FileMaker to an AppleScript subroutine:

// ValuesToApplescriptList
// Function Parameters:
//    fmpList: the return delimited list to convert (terminated by EOL -- watch for trailing carriage return!)

// If the input is null we don't want to create a list with a string and null as it's item.
// just create an empty list instead.

If (fmpList ≠ "";

   // Setup leading brace & qoutes.
   "{"" &

   // Escape any qoutes in the input, and convert carriage returns into delimiters for applescript strings.
   Substitute (fmpList; ["""; "\""]; ["¶"; "",""]) &

   // Terminate the last item in list and close the list expression.

// else



Here’s an excerpt from FileMaker script that shows how you might use this function:

select file (list) 

# Get the list of files to display to user.
Set Variable [ $fileList; Value:Get (ScriptParameter) ] 

# Use applescript to throw up a dialog with list of files. 
Perform AppleScript [ Calculated AppleScript: "choose from list " & ValuesToApplescriptList ($fileList) & "with title "Select File"" ] 


If I pass the select file script the list of values “file ABC¶file XYZ¶lmnop” here’s the dialog I get from AppleScript:



Now you may be asking “…but how do I easily get the value of the user’s selection from the AppleScript dialog?”. For the answer to that you’ll have to wait for a later post.


Leave a Reply