D365FO – AX – Break Statement to exit from While, do-While, for statements

With break keyword when used within a whiledo…while, or for loop, the loop is terminated and execution continues from the statement following the loop as shown in the following example.

    mainMenu = SysDictMenu::newMainMenu();
    enum = mainMenu.getEnumerator();
    found = false;
     
    while (enum.moveNext())
    {
        menuItem = enum.current();
        if (menuItem.label() == parentDictsecuritykey.label())
        {
            found = true;
            break; //Use break to exit from loop
        }
    }
    if (found) //Belongs in Navigation Pane.
    {
        ...
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s