conPeek Function [AX 2012]

Updated: June 28, 2013

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Retrieves a specific element from a container.


anytype conPeek(container container, int number)

Parameter

Description

container

The container to return an element from.

number

The position of the element to return.

Specify 1 to get the first element.

Using an invalid position number, such as -3, 0, or a number higher than the length of the container, might cause unpredictable errors.

The element in the container at the position specified by the number parameter.

The conPeek function automatically converts the peeked item into the expected return type. Strings can automatically be converted into integers and real numbers, and vice versa.


static void main(Args _args)
{
    container cnI, cnJ;
    int i, j;
    anytype aty;
    
    
    info("container cnI ...");
    cnI = ["itemBlue", "itemYellow"];
    
    for (i=1; i <= conLen(cnI); i++)  
    {
        aty = conPeek(cnI, i);
        info(int2str(i) + " :  " + aty);
    }
 
    //
    
    info("container cnJ ...");
    cnJ = conIns(cnI, 2, "ItemInserted");
    
    for (j=1; j <= conLen(cnJ); j++)  
    {
        aty = conPeek(cnJ, j);
        info(int2str(j) + " :  " + aty);
    }
}
/***  Output pasted from InfoLog ...
Message (10:20:03 am)
container cnI ...
1 :  itemBlue
2 :  itemYellow
container cnJ ...
1 :  itemBlue
2 :  ItemInserted
3 :  itemYellow
***/


Announcements: To see known issues and recent fixes, use Issue search in Microsoft Dynamics Lifecycle Services (LCS).

Community Additions

ADD
Show: