This question comes as a result of my VB experience.
If I build a method in Servoy that will act as a function (pass it a number of arguments, it does something with that, and returns a result), why is it that when I call this function from another method, the editor can not show what arguments are required for that function?
For example, when I type
globals.SQL_BuildQueryString()
I have to navigate to my SQL_BuildQueryString method to read my comments about what arguments to pass, what type, and in what order.
In other editors, like VB, if you define a method/function that accepts required or optional arguments, it displays that for you in the editor so you know what to pass (displayed like a tooltip) without having to go look at the function.
Maybe I’m missing something, but it would seem to me that since the Servoy editor uses the keyword “argument”, the editor should be capable of displaying them when you call the method.
Yes, that would be nice. Post a feature request!
Added the feature request.
How would Servoy know which arguments a method/function you created requires?
In the debugger, Servoy now only shows the arguments send into the method/function, as soon as the debugger moved into that method.
This is how JavaScript works. True, in JavaScript you can create a function and in it’s declaration you can specify x named arguments, but that is not something possible now in Servoy. But even if that was possible, the JavaScript named function arguments are still all optional: There is no mechanism in JavaScript that will raise an error if you do not specify the right number of arguments. Only when your logic in the function depend on it, it will raise an error once you reference the arguments that was not send into the function call.
Maybe, in the future, based on your feature request, some system could be implemented so you as a developer can specify on each method you make what the required and optional parameters are, together with their type.
Paul
What could be done, I suppose, is that Servoy checks a method for variable assignments from the arguments array and then simply display those when I move the method. So for example if you have a method test with something like
var myVar = arguments[0], myOtherVar = 5, myThirdVar = arguments[1]
the “move code” could print
test(myVar, myThirdVar)
Of course Servoy will not know what is “optional” and what not.
What about Servoy always showing the first line of comment as a tooltip for the method?
Like this:
// Receive arg1, arg2 and optionally arg3 and returns xxx: test(int arg1,string arg2,number [arg3])
All suggestions are excellent ones; either use a comment line, or simply grab the “var vTable = argument[0]” assignments You perhaps could even introduce a new Servoy keyword.
Functions and arguments are used heavily in most development projects. Not being able to see at least what arguments can be passed to the function when coding is weak, and does not live up to the high quality standard set by this product.
I envision spending a lot of time reviewing comments in functions while attempting to call them from other methods, or worse yet, keeping an external Excel spreadsheet to manually track all functions and arguments.
Bottomline is this is a major handicap compared to all other editors.