Mc128k Posted June 7, 2017 Posted June 7, 2017 I often see that FileMaker native functions use square brackets to define lists, like let ( [ ~var1 = 1 ; ~var2 = 2 ] ~var1 + ~var2 ) Or JSON functions, that actually seem to be "variadic" in the sense that they take a variable number of arguments: JSONSetElement ( "{}" ; [ "id" ; "FB4" ; JSONString ] ; [ "name" ; "Vanilla Cake" ; JSONString ] ; [ "price" ; 17.5 ; JSONNumber ] ; [ "stock" ; 12 ; JSONNumber ] ; [ "category" ; "Cakes" ; JSONString ] ; [ "special" ; true ; JSONBoolean ] ) ] Now, I've been searching for a way to do custom variadic functions, but it seems impossible. And the official documentation doesn't mention the square brackets' real meaning from the language standpoint. What are these "array-like" things exactly? Is there a way to exploit them in custom functions or is it reserved for native functions only? Thanks
comment Posted June 7, 2017 Posted June 7, 2017 (edited) There is no way to define a custom function with a variable number of arguments, or with optional arguments. At most, you can call a function with a list of values as the argument, and have the function recurse over the list. Edited June 7, 2017 by comment
Mc128k Posted June 7, 2017 Author Posted June 7, 2017 Kinda figured it out that already, custom functions do not fully exploit the language. What about the square brackets?
comment Posted June 7, 2017 Posted June 7, 2017 1 minute ago, Mc128k said: What about the square brackets? What about them?
Mc128k Posted June 7, 2017 Author Posted June 7, 2017 (edited) 1 minute ago, comment said: What about them? Just what are they for exactly, the docs don't say how they work and if they are exploitable in some way by custom functions. Edited June 7, 2017 by Mc128k
Wim Decorte Posted June 7, 2017 Posted June 7, 2017 you can't exploit them for custom functions. They work for those native functions that can take a variable set of 'instructions'. Like the Substitute() function that can do substitute a number of combos in one call.
Recommended Posts
This topic is 3086 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 accountSign in
Already have an account? Sign in here.
Sign In Now