Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4952 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

The SMRegisterFunction has been the best thing in the world. It cuts execution time a ton over v1, not to mention script complexity.

However, I got to thinking about whether or not a function might not be registered with a optional argument. My groovy would need to check if a variable is defined, but it would allow for a function "library" to be updated, with the new arguments being optional. So long as sane defaults are set when nothing is declared, the "library" could be updated without any effect on old solutions. ie. no need to update everywhere.

The second thought, was whether pseudo-arrays like in FileMaker's Substitute function - Substitute( text ; searchString ; replaceString {; [searchString ; replaceString]}) - might not be possible. Maybe the arguments get put out as an array, or as a string buffer.

Just a cursory attempt seems to indicate a no, and it isn't the only way to go about things for sure.

If there is a way to do this, that would be great. If not, then maybe it is something to think about in a future version of ScriptMaster. Certainly, ScriptMaster has already been an invaluable tool.

Posted

ScriptMaster doesn't currently support optional arguments, although in theory it would be possible to have a compiled script accept variable/unlimited numbers of arguments. It's not clear how you'd access those items from your script, however, as they wouldn't be named parameters/variables. Maybe have a named parameter which gets converted to an array or List.

SMRegisterGroovy("Foo ( url ; args... )" ; $functionBody )

Something to think about... thanks for the suggestion!

What sort of things would you use this for?

  • Newbies
Posted

Thanks for the response.

As far as optional arguments, I was thinking mostly a way to "future proof" a library full of groovy code. A function could be updated and the new arguments could be optional.

A new function could be added, but it would be nice to update the library and call some sane defaults for missing values from solutions (or pieces of solutions) that haven't been updated yet, while avoiding proliferation of functions.

Also, there is just the idea of having default values like port numbers in an email function.

As for lists, it would just be nice to deal with arrays for things like attachments or information that might accidentally contain common text delimiters. Of course, the delimiters can be substituted out before building the list, and then back in during processing in Groovy. That just means some massaging of data beforehand that would be nice to avoid.

There aren't any deal-breakers to be sure. ScriptMaster allows for things that were impossible or impractical before. These were just some of the first things I thought of when using v2 of the plug-in.

Thanks again for the suggestions.

  • 1 month later...
Posted

The future-proofing is a very good argument. I think we could use a specialized naming convention for the SMRegisterGroovy signature to denote optional elements:

SMRegisterGroovy("Foo ( url ; data { ; optionalArg1 ; optionalArg2 } )" ; $functionBody )

Anything after the opening curly bracket would be considered an optional argument.

I'll work on adding this in to ScriptMaster, please send me any suggestions.

  • 2 years later...
Posted

I would love to have this feature in ScriptMaster. Was this feature ever added? If not, are there plans to add it?

  • 1 month later...
Posted

Is there anything I can do to help add this feature? I could possibly write some code to implement this, or a part of it.

I think this would be a great addition to ScriptMaster, and I would definitely use it in my plug-in project: https://github.com/dansmith65/ooScriptMaster

This topic is 4952 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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