Container Retrieval Example in X++ Language
Table of Content:
Below example shows the typical common scenario where the developer has to read the values from a container in a loop and perform other operations.
Example:
Code:
static void Container_RtrivalExample(Args _args) { // container declaration and initialization with 2 values container containerName = ["Hello", 1202]; str charHolder; int conLength, cnt; ; // looping through container values and printing them to info // most common usage to retrieve values from passed container conLength = conLen(containerName); info(strFmt("Container containerName length/noOfValues = %1 and the values are below", conLength)); for (cnt = 1; cnt <= conLength; cnt++) { charHolder = conPeek(containerName, cnt); info(strFmt("Container containerName %1 value = %2", cnt, charHolder)); } }
Output:
The above code will produce the following result-
Container containerName length/noOfValues = 2 and the values are below Container containerName 1 value = Hello Container containerName 2 value = 1202