Thursday, March 26, 2015

Variable declaration

Variable declaration

Variables must be declared first in the method. We can’t declare the variable inside the X++ statements. In other languages like .net, VB we can declare wherever you want. In AX 2009 we should use semicolon (;) to separate the declaration part and X++ statements like the below code.

AX 2009 variable declaration

int a;
;
a = 5;

But, in ax 2012 semicolon is not necessary (optional). We can assign values in the declaration part.
int a =5;

Variable name

In X++, variable names are not case sensitive. As per the naming convention standard, the first character of the variable name should be small letter. For example:
PurchLine purchLine

Data types

Primitive and composite data types are supported in X++. We can use EDT, table name, class name as data types. For example:
Name                    firstName, lastName;
PurchLIne            purchLine;
Access                  accessObject = new Access();

Multiple variable declaration

X++ allows you to add multiple variable declaration in the same declaration statement. For example:
int i,j;

real a = 5, b=3;

No comments :

Post a Comment