web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    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

  • jsshivalik Profile Picture
    3,099 on at

    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

  • Verified answer
    Tina Menezes Profile Picture
    2,582 on at

    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

    Hi

     Why it is not going in If not found condition

    Thanks

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     When i display found value it shows Yes always

    Thanks

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

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

  • jsshivalik Profile Picture
    3,099 on at

    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

  • Tina Menezes Profile Picture
    2,582 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans