How to use "Var" option when creating a Function in NAV

Hi All,

Plz provide me with example the differnce between Pass by value & Pass by reference in Functions .

Cheers,

Navitech

Where are you seeing these options? What version are you on and where are you?

Hi ,

These are general questions & one of my friends have asked me lately,so i thought to share these with the group.Kindly share your views & knowledge …

Cheers,

Navitech

Hi

I have never heard of these functions in Navision, so I cannot share any knowledge or views.

You will need to tell people where you are in the software, your question is almost cryptic, not helped by the reply either!

This could be a localization, which is why I asked where you were, which you still have not said, and also it could be version specific, hence my other question.

Happy to help if I had more of a clue about what you actually wanted!

Hi Navitech, please use a more descriptive Subject, otherwise it is hard to get a good response. Anyway, Pass by value and pass by reference refer to the VAR tick box in the definition of a Function.

Pass By Reference: If you tick the VAR option, then the actual value entered when calling the function is not passed to the called function, instead a reference is made internally to the memory location where the Variable is stored. What this means is that you don’t use extra memory to define a new variable, and also any changes made to the variable are returned back to the calling function.

Pass by Value, means that the function creates a new variable, and that variable is NOT returned back to the calling function.

For more examples see

e.g. http://www.cs.princeton.edu/~lworthin/126/precepts/pass_val_ref.html

http://www.maths.cam.ac.uk/undergrad/catam/ccatsl/manual/node50.html

http://www.javacertificate.net/passbyvalue.htm

I know that it is not C/AL but this is general thing…

Nope that has all completely gone over my head and there I was thinking I was in teh beginners forum [:D]

When you create a new function in Navision, and you pass a variable, there is a tick box “VAR” if you tick it, then the actual variable is passed to the function, and any changes you make are passed back tot he calling function, including filters and sorting if it is a record. If you don’t tick it, then a copy is made of the variable, and it is temporarily used, and then dumped when the function finishes.

Hi to All,

thx a lot for your valuable inputs …sorry for not putting my question correctl though. This forum is of graet help to all of us …

Cheers,

Navitech

Glad to be off help. PS please click the button “Mark As Anser” on the reply(s) that helped you, and mark the issue as resolved. thanks.