Solved

How to skip some looping  step in do-while statement

Posted on 2004-04-28
4
418 Views
Last Modified: 2013-11-20
Hi, experts!

In my  CMyView::OnInitialUpdate()
I am reading from text file and populating the data in
ListView line by line:

      // Open the text file we want
      CFile cfFile ("C:\\data.txt", CFile::modeNoTruncate | CFile::modeRead);

      CArchive ar (&cfFile, CArchive::load); // Load its contents into a CArchive

      // Initialise the variable which holds each line's contents
      CString strLine = "";
      if(!ar.ReadString(strLine))
      // Read the first line of the CArchive into the variable
            return; // Failed, so quit out

        int i = 0;


      do // Repeat while there are lines in the file left to process
      {

            if(strLine.GetLength() == 0) // If the line is empty, skip it
                  continue;



            CString strText = strLine; // A line of the file

            // Initialise the variables that will hold the values
            CString str1 = "";
            CString str2 = "";
            CString str3 = "";
            CString str4 = "";
            CString str5 = "";
            CString str6 = "";

            // Extract the first value, and place it in the str1 variable
            AfxExtractSubString(str1, strText, 0, ',');
            // Extract the second value, and place it in the str2 variable
            AfxExtractSubString(str2, strText, 1, ',');
            // Extract the third value, and place it in the str3 variable
            AfxExtractSubString(str3, strText, 2, ',');
            // Extract the second value, and place it in the str4 variable
            AfxExtractSubString(str4, strText, 3, ',');
            // Extract the second value, and place it in the str5 variable
            AfxExtractSubString(str5, strText, 4, ',');
            // Extract the third value, and place it in the str6 variable
            AfxExtractSubString(str6, strText, 5, ',');

            // Do something with these values in the variables



      InsertRow(i, str1, str2, str3, str4, str5, str6);

      i++;

      }while(ar.ReadString(strLine));


The question is how to skip step i = n, where int n is some veriable

Looking forward for your help


0
Comment
Question by:khlauster
  • 2
4 Comments
 
LVL 13

Expert Comment

by:SteH
Comment Utility
if (i == n)
   continue;
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
    do // Repeat while there are lines in the file left to process
     {

          if ( i == n )
              continue;
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 125 total points
Comment Utility
Oops...

if (i == n)
{
   i++;
   continue;
}
0
 

Author Comment

by:khlauster
Comment Utility
if (i == n)
{
   i++;
   continue;
}

is the right one!

Thank you, AlexFM.

P.S. :
if (i == n)
   continue;

brings only first line out my text file,

Thanks for trying to help me anyway, SteH.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now