Optional Parameters

MagnoMagno Member Posts: 168
edited 2005-07-13 in Navision Attain
Hi,

Is it possible to write a function with optional parameters?

Grtz
There are no bugs, only random undocumented features...
---
My Blog: http://NAV-Magno.be

Comments

  • DenSterDenSter Member Posts: 8,307
    Nope, no such thing as optional parameters in C/AL. You add a parameter to a function, you have to find all references to it and change them.

    You could create a new function with the additional parameter and add a call to the new one in the old one with a default value for the new parameter.
  • krikikriki Member, Moderator Posts: 9,112
    Or use a codeunit that is single-instance. Put the optional parameters in it and then call your function.

    Or add 1 parameter as text 1024 and put in it all your optional parameters as text
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • awarnawarn Member Posts: 261
    Create a new table, each field in the table will act as a parameter.

    Make this table the only parameter in the function.

    Fill the table, then call the function, if you define it as temporary in both places (in the code and as a parameter) you wont need it to be in the license.

    If you need to add more parameters then just add more fields to the table.

    -a
  • krikikriki Member, Moderator Posts: 9,112
    Or to save a table, use an existing table.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • awarnawarn Member Posts: 261
    If you declare the table as temporary in both places you won't be wasting a table in the license.

    I'd rather do that than add fields to a table, which will be blank all the time, but still potentially take up space in the database with all of the other records in the table. A temporary table never holds data on the server so no space will be taken up in the database.

    For example, if you add 10 decimal fields to the item ledger entry you make that table bigger for all the records that are in there - if you like the structure of that table so much just make a copy of it outside the license and keep it declared as temporary everywhere you declare it in code.

    -a
Sign In or Register to comment.