Showing posts with label Functions. Show all posts
Showing posts with label Functions. Show all posts

LOCAL FUNCTIONS AND VARIABLES

LOCAL FUNCTIONS AND VARIABLES
Local Functions
A local function is a function that can be called in the object in which it is defined. Any function that not be defined by local function called from other objects as well as the objects from which its defined.
Local Variables
A local variable is avariable whose scope is limited to single function. This means that in this function trigger code, a local variable can be used like any other variable. If the name of a local variable is reffered outside of the function in which it is defined, syntax error will result.

FUNCTION PARAMETERS

FUNCTION PARAMETERS IN MICROSOFT DYNAMICS

Function parameter is one or more variables or expressions that are sent to the function through a function call. These parameters provided for function information also can able to modify that information. If there is more than one parameter, the parameters will be sepearated by commas.

There are mainly 2 types of parameter passing occur

  1. Pass By Value
  2. Pass By Reference
  • Pass By Value:- In this type of parameter passing only pass some values only. If we change thse values then it will not affect in the parent trigger or values. That is once pass the value it will not affect any kind of changes in the parent method, its only passing the value.
  • Pass By Reference:- In this kind of parameters its pass like reference of the variable, sometimes called name of the variable. Whenever we change the value of these variables it will affect the parent trigger also. Because in this type the computer knows the exact storage space of that variable or parameter. 

FUNCTIONS IN MICROSOFT DYNAMICS

FUNCTIONS IN MICROSOFT DYNAMICS

Definition

Functions are named portions of a program, some times called as Subprogram or Subroutine.

When a function is called from a set of programming code then current programming code is suspended and continued with a trigger code. And after the completion of that trigger the program control return to the origin. 

A function can be used as expression also

For example:

TotalCost := Qty * CalculatePrice

In this code CalculatePrice is one function that calculate the price and after the calculation it return some value based upon that further programming codes executes.

Built In Functions

In Microsoft Dynamics C/SIDE programming using some built in functions also. These programming codes cannot be viewed by the users and it cannot be modified.

Some of the built in functions are as follows

  • MESSAGE :- Displays a message on the screen.
  • MAXSTRLEN :- Return defined legth of string variable.
  • COPYSTR :- Returns part of a string
  • CLEAR :- Clears the passed in variable
  • ARRAYLEN :- Returns number of elements in an array.

CLEAR

CLEAR() In Microsoft Dynamics NAV C/AL

CLEAR() is used to clear the Variable. The sysntax of CLEAR()  is 

CLEAR(Variable);

CLEAR () clears the variable in the manner like if the Variable is Integer then the Variable value reset to zero. And if the variable is String then the Variable value reset to empty.

For Exapmple,

If you want to reset a Result variable that stores the sum of previous calculation then you have to mension 

CLEAR(Result);

After executing this line the calue Result goes to zero.

So the CLEAR () is most usable function in the good C/AL programing.

Related Posts with Thumbnails