?
Solved

How to skip some looping  step in do-while statement

Posted on 2004-04-28
4
Medium Priority
?
424 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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