"while", what's wrong in my code? - page 2

 
WHRoeder:

if(cc>1 || cc == 0){    When is this condition ever going to be false?
    Sleep(INTERVAL_MILLIS);
    continue; 
    }
   NEVER REACHED

When cc =1, the following part will be reached.

I think this bug is because I put "ObjectCreate("test09msg",OBJ_TEXT,0,t,WindowPriceMax());" outside/before "while()...", so variable "t" is empty/zero.

 
joshatt:


It works perfect. I can learn a lot from your code. And I have to form a good process of debugging.... random try this and that won't help. Sometimes I have to calm down to find fault. LOL.

Exactly, sounds like you are learning some valuable lessons, keep this thought foremost in your mind
 
WHRoeder:
No it will not. cc == 1 the if calls sleep and the continue goes back to the top of the while.


I wrote another example script to test:

int start()
  {
//----
int cc=1;
while( !(IsTesting() || IsStopped()) ) {
   if(cc>1 || cc == 0){       //  When is this condition ever going to be false?
    Sleep(1000);
    Comment("inside if");
    continue; 
   }
Comment("reached");
Sleep(1000);
}
//----
   return(0);
  }

I see "reached".

 
joshatt:


I wrote another example script to test:

I see "reached".


Of course, if cc=1 the if condition is false.
 
WHRoeder:
No it will not. cc == 1 the if calls sleep and the continue goes back to the top of the while.

cc = 1 does not make . . .

(cc > 1 || cc == 0)

. . . true. cc is not greater than 1 and it is not equal to 0

 
RaptorUK: cc = 1 does not make . . .
(cc > 1 || cc == 0)
What happened to that greater or equal sign I imagined seeing all day? Shame
 
WHRoeder:
RaptorUK: cc = 1 does not make . . .
What happened to that equal sign I imagined seeing all day?

I think you must have caught my temporary blindness disease . . .
 

I published this code.

~Cheers.

Reason: