Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

ArrayReformat ( valueList ; quoteStyle ; braceStyle ; newSeparator ; oldSeparator )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.0  (3 votes)
  Discuss this Custom Function

Julio Toledo, Automation USA LLC
http://www.automationusa.net

Convert/transform lists to JSON, quoted lists, or other name value pairs

Sample Input:
ArrayReformat ( "item1¶item2¶item3¶item4" ; "'" ; "" ; "" ; "" )

ArrayReformat ( "item1¶item2¶item3¶item4" ; "\"" ; "{}" ; "" ; "" )

ArrayReformat ( "Label-A¶Label-B¶Label-C¶Label-D" ; "«»" ; "[]" ; "; "; "" )

ArrayReformat ( "Label-1,Label-2,Label-3,Label-4" ; "\"" ; "null" ; "¶"; "," )
Sample Output:
('item1','item2','item3','item4')

{"item1","item2","item3","item4"}

[«Label-A»; «Label-B»; «Label-C»; «Label-D»]

"Label-1"¶"Label-2"¶"Label-3"¶"Label-4"


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

ArrayReformat can be used to transform any list (values separated by any separator [returns, commas, strings, etc.) into any other syntax string using new punctuation and value separators.

Use cases include converting CSV to JSON values, creating quoted lists for SQL "IN" queries as well as to create properly formatted JSON by combining name lists and value lists using a recursive function

Examples:
ArrayReformat ( "Label1,Label2,Label3,Label4" ; "\"" ; "null" ; " : " ; "," ) returns —-> "Label1" : "Label2" : "Label3" : "Label4"

ArrayReformat ( "Label1¶Label2¶Label3¶Label4" ; "«»" ; "" ; "; " ; "" ) returns —-> («Label1»; «Label2»; «Label3»; «Label4»)

ArrayReformat ( "item1¶item2¶item3¶item4" ; "'" ; "" ; "" ; "" ) returns —-> ('item1','item2','item3','item4')

Create quoted lists for executing SQL queries such as "SELECT firstname,lastname,city,state FROM myContacts WHERE state IN ('MI','IN','OH')":
ArrayReformat ( "MI¶IN¶OH" ; "'" ; "" ; "" ; "" ) returns —-> ('MI','IN','OH')

Create well formed JSON and other name-value pairs by using in conjunction with a merge array function ( such as "ArrayCombine" http://www.briandunning.com/cf/2037). For example:

Let ( [

list1 = ArrayReformat ( "Label1¶Label2¶Label3¶Label4" ; "\"" ; "null" ; "¶" ; "" ) ;
list2 = ArrayReformat ( "fantastic!¶...but what about¶a syntax for adding¶an element to the END of an array?" ; "\"" ; "null" ; "¶"; "" )
] ;

//calculation
ArrayReformat ( ArrayCombine ( list1 ; list2 ; 1 ; " : " ) ; "{}" ; "[]" ; " , " ; "" )
)

Returns the following JSON —> [{"Label1" : "fantastic!"} , {"Label2" : "...but what about"} , {"Label3" : "a syntax for adding"} , {"Label4" : "an element to the END of an array?"}]

NOTES:
To opt out of the enclosing "braceStyle" punctuation, Use "null" parameter value

RELEASE:
2017-04-27 - Initial release by Julio Toledo, Automation USA, LLC
2017-05-05 - Modifications by Julio Toledo, Automation USA, LLC:
* renamed function from "ReformatArray" to "ArrayReformat"
* added "oldSeparator" optional parameter, which provides the ability to substitute any existing value separator for any other separator (defaults to return "¶")

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 8 + 9 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. ProperAllWords ( text )
  (Thu, Dec 14, 5:19pm)
2. MatchExist ( SourceTable.Field ; DestTable.Field ; ReturnField )
  (Thu, Dec 14, 1:07pm)
3. BVR_Format ( bvr )
  (Wed, Dec 13, 5:32pm)
4. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
5. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
6. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
7. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
8. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)

RSS Feed of Custom Functions