Weird!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michel Racicot

    Weird!

    I got a REALLY weird behavior...

    In the following code,

    if (sCurrentToken != "")
    {
    lstArrayLine.Ad d (sCurrentToken) ;
    sCurrentToken = "";
    }

    when sCurrentToken is equal to "" (empty string), the sCurrentToken = "";
    line, is EXECUTED!!! (but not the .add ( ) line...)

    I traced and I really see the line being executed!!! How can this be
    possible!?


  • mikeb

    #2
    Re: Weird!

    Michel Racicot wrote:
    [color=blue]
    > I got a REALLY weird behavior...
    >
    > In the following code,
    >
    > if (sCurrentToken != "")
    > {
    > lstArrayLine.Ad d (sCurrentToken) ;
    > sCurrentToken = "";
    > }
    >
    > when sCurrentToken is equal to "" (empty string), the sCurrentToken = "";
    > line, is EXECUTED!!! (but not the .add ( ) line...)
    >
    > I traced and I really see the line being executed!!! How can this be
    > possible!?
    >
    >[/color]

    This is a debugger bug. It shows the line being executed, when in fact
    it is not. I can't recall at what point this bug was fixed.

    --
    mikeb

    Comment

    • sasha

      #3
      Re: Weird!

      I had this problem before. It causes by your Dlls. Remove that part of code,
      build it, and then type it again. If it doesn't work do this:

      if (sCurrentToken == "")
      {
      doSomething.... ..
      }
      else
      {
      lstArrayLine.Ad d (sCurrentToken) ;
      sCurrentToken = "";
      }

      hope it helps

      sasha

      "Michel Racicot" <michel.racicot _NO_SPAM_@cgi.c om> wrote in message
      news:uZcTYtmnDH A.2528@TK2MSFTN GP12.phx.gbl...[color=blue]
      > I got a REALLY weird behavior...
      >
      > In the following code,
      >
      > if (sCurrentToken != "")
      > {
      > lstArrayLine.Ad d (sCurrentToken) ;
      > sCurrentToken = "";
      > }
      >
      > when sCurrentToken is equal to "" (empty string), the sCurrentToken = "";
      > line, is EXECUTED!!! (but not the .add ( ) line...)
      >
      > I traced and I really see the line being executed!!! How can this be
      > possible!?
      >
      >[/color]


      Comment

      • Juan Gabriel Del Cid

        #4
        Re: Weird!

        Are you 100% sure your code isn't:

        doSomething();

        if (sCurrentToken != "")
        lstArrayLine.Ad d (sCurrentToken) ;
        sCurrentToken = "";

        doSomethingElse ();

        Leaving out braces for an if statement is quite common. Given the fact that
        you actually indent the code it makes it harder to realize it really is a
        mistake. This has happened to me many times.

        -JG


        Comment

        Working...