Saturday, 29 March 2014

Containers in Ax 2012 with examples.

Containers :

  - Containers are used to store different datatypes
  - Max columns in a container - 50

>> some important functions :

conlen - gives the length of the container
conpeek - gives the value of an element based on the index
conpoke - used for replacing any element with new element value
condel - willl delete the elements in cotnainer based on the start postion and number of elements to be deleted
connull - will empty the container
conins - will help to insert new elements to container
conview - to viuew the elements in the container - onyl for unit testing

confind - to find a particular element exists in container - it will give u the postiion/index

>> Just look at the following example to undestand how these methods can be applied :

static void TDS_Containers(Args _args)
{
    Container con = [1000, "Rahul", 5000.00, 56];
    container resultCon;
    int i;
    int position;
    // container limit is 50 columns
    ;
   
    // container index starts with 1
   
    // to get the length of the container
    info(int2str(conlen(con)));
   
    // to get any value based on the index use conpeek() function
    info(conpeek(con, 3));
   
    // to get all the values in one shot
   
    info("__________________________________");
   
    for ( i = 1; i <= conlen(con); i++)
    {
        info(conpeek(con,i));
    }

    info("__________________________");
   
    resultcon = condel(con, 2,2);
   
    conview(resultcon); // this should be only used for testing purpose
   
    // to nullify to empty the container
   
    //con = connull();
   
    //info(int2str(conlen(con)));
   
    //
    // To insert any new valuezs into container - use conins()
    // To replace any value in the container - use conpoke()
    // to find any value in container- use confind
   
    position= confind(con, "sreedhar");
   
    info(strfmt("sreedhar is found at %1 position", position));
}

Hope u find this useful... :)

2 comments:

  1. Its helpful to me Thank Q you....

    ReplyDelete
  2. Can u explain a little bit more the "Max columns in a container - 50"?

    ReplyDelete