July 28, 200817 yr Newbies 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.
July 31, 200817 yr 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?
July 31, 200817 yr Author Newbies 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.
September 4, 200817 yr 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.
May 15, 201114 yr I would love to have this feature in ScriptMaster. Was this feature ever added? If not, are there plans to add it?
May 17, 201114 yr It's on our list of things to do for ScriptMaster, but I definitely do not have a date for you.
July 8, 201114 yr 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
July 11, 201114 yr We could do this for you as a custom development project for you. Our rate is $165/hour. If you're interested, send an email to [email protected] and we can get you a quote.
July 11, 201114 yr Sorry, I don't have the funds for that. All I can offer is my own development time.
Create an account or sign in to comment