3 Replies Latest reply: Oct 6, 2012 7:54 PM by Charlie Arehart RSS

    Using CFScript statements

    Community Help Community Member
        • 1. Re:  Using CFScript statements
          p.sim Community Member

          The code example loops through a query that uses do-while() is a poor example. It should utilize while(). We want to check first if there is a result set. If there is, then read the record. Using while() would eliminate the use of if() statement prior do-while(). do-while() means we want to run the first loop, then check a condition whether or not to run the subsequent loop. while() means we want to check if the first and subsequent loop is true.

          • 2. Re:  Using CFScript statements
            CF-AXL Community Member

            For the last code, an opening angle bracket (<) is missing in the opening cfscript tag.

            • 3. Re:  Using CFScript statements
              Charlie Arehart CommunityMVP

              More than that, the example (showing a do-while to loop over a query) can be removed as of CF10 with its new support for for-in looping over a query (shown near the bottom of this page). As there are other examples of do-while loops offered above it, there's really no need even to replace it with something else.