Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Square brackets semantics in functions

Featured Replies

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

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 by comment

  • Author

Kinda figured it out that already, custom functions do not fully exploit the language. What about the square brackets?

1 minute ago, Mc128k said:

What about the square brackets?

What about them?

  • Author
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 by Mc128k

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.

  • Author

That confirms my hypothesis.. Thanks

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.