Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Exit from the loop

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  If found i want to exit from loop . Secondly i have taken found as Text. I want to take it as Boolean then how to check True or False condition

      WHILE Ctr <= 10 DO BEGIN
        IF GLEntry."G/L Account Name" =  AccountName[Ctr] THEN BEGIN
          AccountValue[Ctr] += GLEntry.Amount;
          found := 'TRUE';
        END;
        Ctr := Ctr + 1;
      END;
      
 


Thanks

*This post is locked for comments

  • Tina Menezes Profile Picture
    2,582 on at
    RE: Exit from the loop

    Hi

    Where have you written this code?

    You'll need to write a GLEntry.find or findfirst statement after the following line

    IF NOT found  THEN BEGIN

  • jsshivalik Profile Picture
    3,099 on at
    RE: Exit from the loop

    Hi

     Before the loop i have initialized as

    found := FALSE;

    Secondly when i display message  MESSAGE('%1',GLEntry."G/L Account Name"); in the loop it shows blank

    Thanks

  • Suggested answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: Exit from the loop

    make  found := false; between while condition line and IF condition line

  • jsshivalik Profile Picture
    3,099 on at
    RE: Exit from the loop

    Hi

     When i display found value it shows Yes always

    Thanks

  • jsshivalik Profile Picture
    3,099 on at
    RE: Exit from the loop

    Hi

     Why it is not going in If not found condition

    Thanks

  • Verified answer
    Tina Menezes Profile Picture
    2,582 on at
    RE: Exit from the loop

    Hi.

    You can define Found as boolean variable and try below code

     WHILE Ctr <= 10 DO BEGIN

           IF GLEntry."G/L Account Name" =  AccountName[Ctr] THEN BEGIN

             AccountValue[Ctr] += GLEntry.Amount;

             found := TRUE;

           IF found = TRUE then

            EXIT;

           END;

           Ctr := Ctr + 1;

         END;

  • jsshivalik Profile Picture
    3,099 on at
    RE: Exit from the loop

    Hi

      NOt going in if not foundcondition

    found := False;

             WHILE (Ctr <= 10) DO BEGIN
            IF GLEntry."G/L Account Name" =  AccountName[Ctr] THEN BEGIN
              AccountValue[Ctr] += GLEntry.Amount;
              found := TRUE;
            END;
            Ctr := Ctr + 1;
          END;
          
          IF NOT found  THEN BEGIN
            AccountName[g_ctr] := GLEntry."G/L Account Name";
            AccountValue[g_ctr] := GLEntry.Amount;
            g_ctr := g_ctr + 1;
            MESSAGE('%1','in');
          END;

    Thankss

  • Suggested answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: Exit from the loop

    try this code. I didnt test

    WHILE (Ctr <= 10) OR found DO BEGIN

           IF GLEntry."G/L Account Name" =  AccountName[Ctr] THEN BEGIN

             AccountValue[Ctr] += GLEntry.Amount;

             found := TRUE;

           END;

           Ctr := Ctr + 1;

         END;

    found is boolean type

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans