Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to skip some looping  step in do-while statement

Posted on 2004-04-28
4
Medium Priority
?
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 10940190
if (i == n)
   continue;
0
 
LVL 48

Expert Comment

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

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

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10940198
Oops...

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

Author Comment

by:khlauster
ID: 10940643
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 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