Code runs correctly everytime when started with F10 with cursor within the IF statement code, will not run correctly normally.

Posted on 2006-05-09
Last Modified: 2010-04-17
Hello experts,
I have a piece of WTL C++ code that I have written, which works fine if it is run in debug mode (i.e. when started with F10 with say the cursor within the Message box code (which means the program runs correctly without stopping)), all the variables are returning correct values but when I run the code started normally it runs the error message box everytime, I cannot find the problem because it always works correctly when debugging,  Any ideas please, a fragment of the  code is included to assist. ComboEdit.ReadComboBox is an external class method, ReadRadioButton and ClearRadioButton are simple methods within this class, all of which work OK. This is being compiled in debug mode, not release mode incidentally.

      switch (ClickedButton)
      case 1:
            fDepthLog = atof(ComboEdit.ReadComboBox(hwndTool1LoggingInterval));
            if(fDepthLog <0.001)
                  MessageBox("Logging Interval NOT Yet Selected", _T(ErrorBoxString), MB_ICONERROR|MB_OK);
            //Error box if user has not selected a value in the combo box.

Help please, this code should be elementary but its unexpected behaviour is driving me nuts.

Question by:racurrell
    LVL 1

    Accepted Solution



     as i dont know the prvious code
     i can predict only one thing
     that u can not compare floats like this
     u r converting string to float using "atof"
     then ur comapring it with 0.001
     do one thing make the decimal places of the float to three  , like (0.001) then compare it
     i think that will work
     if its useful
     let me know


    Author Comment

    Thanks Tushar,
    you are on the right track, I came to a similar conclusion and made it work just after I wote the note to Experts Exchange.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now