I think, that it is no possible to have function with variable count of parameters. No way how to do that. No way to set default value for some parameter, no way how to define more functions with same name but another parameter count.
But> one place where are functions with variable count of parameters exist> automations.... if you look to some code with automations, there are used many functions with default parameters...
and then ofcourse the usual
Rec.setfilter(field1,parameter1);
Rec.setfilter(field2,Parameter2);
Rec.setfilter(field3,Parameter3);
etc etc.
and now you have your parameters.
If you want the window to open optionally you should place a condition before executing the above script;
Thanks.
I cannot use dialog (i shall use this codeunit within NAS so userinput is impossible). Optional parameters would have been 'nice to have', but I will find a way around..
Create a table, the fields are possible parameters (so you can have corrcet format)
On this table, you set a unique ID for each row.
When you call your function, you write the rox with your parameters, and give the unique ID to your function.
Your function retrieve row parameters (with ID) and work
Comments
But> one place where are functions with variable count of parameters exist> automations.... if you look to some code with automations, there are used many functions with default parameters...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
define the following variables:
Name Type
ParameterInput Dialog
Parameter1 Integer
Parameter2 Integer
Parameter3 Integer
Text Constant:
Name ConstValue
Text1000000003 Please Specify the parameters\Parameter1 #1#######\Parameter2 #2#######\Parameter3 #3#######
On top of your script place this code
ParameterInput.OPEN(Text1000000003)
ParameterInput.INPUT(1,Parameter1);
ParameterInput.INPUT(2,Parameter2);
ParameterInput.INPUT(3,Parameter3);
ParameterInput.CLOSE;
and then ofcourse the usual
Rec.setfilter(field1,parameter1);
Rec.setfilter(field2,Parameter2);
Rec.setfilter(field3,Parameter3);
etc etc.
and now you have your parameters.
If you want the window to open optionally you should place a condition before executing the above script;
Hope this helps
I cannot use dialog (i shall use this codeunit within NAS so userinput is impossible). Optional parameters would have been 'nice to have', but I will find a way around..
- T.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Function(Param1,...,Var OptionParameter:option);
and return value into OptionParameter.
something as calling MESSAGE(Text000), or MESSAGE(Text000,P1) etc...
[/code]
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Unfortunatly, Navision is not object-oriented programming , but only based on it. :?
Create a table, the fields are possible parameters (so you can have corrcet format)
On this table, you set a unique ID for each row.
When you call your function, you write the rox with your parameters, and give the unique ID to your function.
Your function retrieve row parameters (with ID) and work
...
I think it's the "best" solution with Navision
Where with little exertion
And with extra-vision
You find through-ass solution.
:P