Best way to omit optional parameters in formulas?

What is the best way to bypass parameters you don’t want to set in a formula?

For example:
Gmail::SendEmail([User's private Gmail account], "testemail@email.com", "Subject", "Body")

That does the job, even without including optional parameters that I didn’t need to set (before today :wink:). However, what if I want to add an optional parameter far down the list but not change any other optional parameters? Like the new hideSignature parameter of the SendEmail functionso:

Gmail::SendEmail([User's private Gmail account], "testemail@email.com", "Subject", "Body",,,,,true)

In Visual Basic (for instance) this is valid. But Coda doesn’t like this syntax. The only idea I’ve got so far is to use empty strings ("") for parameters in-between. Like this:

Gmail::SendEmail([User's private Gmail account], "testemail@email.com", "Subject", "Body","","","","",true)

Do these empty strings cause problems? (Not just in the SendEmail function but in others as well) Is there a better method? Maybe _noop() in each parameter? (doesn’t seem right, and it’s tedious to type out multiple times in one formula)

These are “named parameters” and should work using the following strategy (using Image() as an example):

Image("https://myimageurl.com",height: "100")

Where the possibilities for parameters are…

Image​(url, width, height, name, style​)

So using the parameter name:, then the value in quotes, should keep you from having to add placeholders.

4 Likes

Thanks, Ben! I see how this works (I’ve seen those “named parameters” on this community but didn’t really see why they were necessary).

This would be a good addition to the Hard to Discover list, as I can’t seem to find mention of “named parameters” or “named arguments” anywhere else.

5 Likes