Ax 2012 Arrays

An array is a collection of variables that are all of the same type. The elements of an array are accessed with simple integer indexes.

There are three kinds of arrays:

  • Dynamic
  • Fixed-length
  • Partly on disk

X++ only supports one-dimensional arrays. It is possible, however, to mimic the behavior of multiple array indices.

Example JOB:

static void ArrayTypes(Args _args)
Name DynamicArray[];
Name FixedArray[4];
//Name PartllyOnDiskArray[,8]; // if you use like this then it is Dynamic array of Name only 8 in memory
Name PartllyOnDiskArray[16,8];// if you use like this then it is Fixed length array of Name wit 16 elements and 8 in memory

int i,j;
 CustTable custTable;

while select AccountNum from custTable
where custTable.CustGroup==”30″
DynamicArray[i] = custTable.AccountNum;

FixedArray[i] = custTable.AccountNum;

PartllyOnDiskArray[i] = custTable.AccountNum;

setPrefix(“Array Types”);
for (j=1;j<=dimOf(FixedArray);j++)
info(strFmt(“Fixed Array – %1”,FixedArray[j]));
setPrefix(“Dynamic Array”);
for (j=1;j<=dimOf(DynamicArray);j++)
info(strFmt(“Dynamic Array – %1”,DynamicArray[j]));
setPrefix(“PartlyOnDisk Array Memory value”);
for (j=1;j<=dimOf(PartllyOnDiskArray);j++)
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));
setPrefix(“PartlyOnDisk Array fully printed (Disk + Memory)”);
for (j=1;j<=16;j++)
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s