Newbies DM&A Posted July 28, 2008 Newbies Posted July 28, 2008 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.
shmert Posted July 31, 2008 Posted July 31, 2008 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 DM&A Posted July 31, 2008 Author Newbies Posted July 31, 2008 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.
shmert Posted September 4, 2008 Posted September 4, 2008 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.
dansmith65 Posted May 15, 2011 Posted May 15, 2011 I would love to have this feature in ScriptMaster. Was this feature ever added? If not, are there plans to add it?
Smef Posted May 16, 2011 Posted May 16, 2011 ScriptMaster does not currently support optional parameters.
dansmith65 Posted May 17, 2011 Posted May 17, 2011 Are there any plans to support optional parameters?
Smef Posted May 17, 2011 Posted May 17, 2011 It's on our list of things to do for ScriptMaster, but I definitely do not have a date for you.
dansmith65 Posted July 8, 2011 Posted July 8, 2011 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
Smef Posted July 11, 2011 Posted July 11, 2011 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.
dansmith65 Posted July 11, 2011 Posted July 11, 2011 Sorry, I don't have the funds for that. All I can offer is my own development time.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now