ConFind() Function in Container | X++ Language

Rumman Ansari   Software Engineer   2020-03-04   8368 Share
☰ Table of Contents

Table of Content:


  • The conFind() is used to find the first occurrence of an element or a sequence of elements in a container.
  • Syntax: int conFind (container container, anytype element,... )
    • container - The container to search.
    • element - One or more elements to search for, separated by commas.
  • Return value: Returns 0 if the item was not found; otherwise, the sequence number of the item.

Example:

Code:


static void Container_conFindExample(Args _args)
{
// container declaration and initialization with 2 values
    container containerName = ["Welcome", 1202]; 
    str charHolder;
    ;

    // conFind() function finds position in the container that a certain value is being held (if found)
    info(strFmt("conFind() - Find '1202' value in containerName container return if true(indexNo) else (0):- %1", conFind(containerName, 1202)));
    info(strFmt("conFind() - Find '2' value in containerName container return if true(indexNo) else (0):- %1", conFind(containerName, 2)));
}

Output:

The above code will produce the following result-


conFind() - Find '1202' value in containerName container return if true(indexNo) else (0):- 2
conFind() - Find '2' value in containerName container return if true(indexNo) else (0):- 0