Skip to main content

Containers

In X++, container is one of the primitive types, or value types. container is not a class. A container contains an ordered sequence of primitive values or other containers.
container can be stored in the database. container is one of the column types that you can select when you use the Application Object Tree (AOT) to add a column to a table.
container slightly resembles an array, or collections such as the List or Stack classes. However, you can never change the size or content of a container after the container is created. X++ statements that appear to modify a container are internally building a new container and copying values as necessary. Even an assignment of a container to another container variable creates a new copy of the container. All of this has performance implications.
In the X++ functions that provide access to a container (such as conPeek), the container is 1 based not 0 based. Indexing is 1 based for arrays, and for everything else in X++.
Inserts one or more elements into a container.

Syntax:

container conIns (container container,int start,anytype element,... )
Example:
static void conInsExample(Args _arg)
{
    container cr2 = [1, "blue", true];
    container c;
    int i;
    ;
 
    c = conIns(c,1,"item1");  
    c = conIns(c,2,"item2");
    for (i = 1 ; i <= conLen(c) ; i++)  
    {
    // Prints the content of a container.
        print conPeek(c, i);
    }
    pause;

}

container is helpful when you must pass a variety of value types between the client and server tiers.
container is a poor choice when you intend to repeatedly add to a list in a loop.

Comments

Popular posts from this blog

Adding lookup method on Form Reference Group AX 2012

Reference Group Control lookups in AX 201 2 With the addition of reference groups fields the AX forms including the dialog form gives a rich control called the FormReferenceGroupControl.  With this post, I will show you how to add a reference field in the batch dialog form and add a filtered query controlled drop down. I am going to show with a EcoResCategoryId field. The requirement is to filter out categories with Level 3 and present in the batch dialog dropdown.   Class Declaration:  Declare the warehouse and category fields and dialog fields as below. InventLocationId            inventLocationId; EcoResCategoryId            EcoResCategoryId; DialogField                 DialogInventLocationId,DialogEcoResCategoryId; Dialog Method: public  Object ...

Important function in x++ for AX 2009 and AX 2012

Important function in X++ I would like to share some important function in x++ Like subStr(), strCmp(),strDel() , strFind (),strfmt () , strLen (),strLwr (),strUpr (),strRep(),systemDateGet(),today(),trunc (),boxExample (),conins(), conLen(), conPeek(), conNull() which seems to easy but some time became very tough to recall in between to coding, so don’t worry and keep coding……. Sub String in X++ // for cut a string from given posititon SubStr("ABCDEFGHIJ",7,-4) returns the text string "DEFG" (the specified sub-string). static void subStr(Args _args) {   str s;   real  r;    ;     r = strLen("jitendraknit@gmail.com");     s = subStr("jitendraknit@gmail.com",12, 2);      print(strFmt("s=%1 and r=%2",s,r));      pause; } String Comparison in X++ static void strCmp(Args _args) {   int i=2;   str s1,s2;    ;      s1="string 1";      //s2...

Dynamics Ax Table collections & Virtual company

If using more than one company, sometimes, it will be useful to share data from tables with general information, like, tables storing data like zip codes and country codes. The most basic way to share data from a table among all companies is to set the table property SaveDataPerCompany to No. This will merge data for the table and make the data accessible from all companies. In practice, the kernel will delete the system field dataAreaId for the table. Another way to sharing data without having to change any settings in the existing tables is by using Table Collections. A table collection is just a template for tables to be shared by any number of companies and Table collections shared using a virtual company. The form SysDataAreaVirtual is used to define virtual companies. Virtual company is a term used for sharing table collections among a set of companies and does not exist in reality, and therefore, you cannot switch to a virtual company like any normal company. When using ...