[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] If statement expression variable



PureBytes Links

Trading Reference Links



Dear reader

I seem to find that if one changes the value of a variable used in 
the expression of an if statement "IF(<expression>)" then the if 
statement fails - even the first one before the value has been 
changed to something that would return false.

For eg. ***Stuff*** is never executed:

//global Var;
Var = 0;
for ( i = 1; i < BarCount; i++) {

//if( i == 1 ) Var = 0;

  if( Var == 0 ) {
     *** Stuff ***
     Var = 1;
  } 
}

These two examples do reach ***Stuff*** but are logically incorrect:

Var = 0;
for ( i = 1; i < BarCount; i++) {
  if( Var == 0 ) {
     *** Stuff ***
//     Var = 1;
  } 
}

for ( i = 1; i < BarCount; i++) {
  Var = 0;
  if( Var == 0 ) {
     *** Stuff ***
     Var = 1;
  } 
}

Even executing "Var = 1;" outside the if statement causes it to fail. 
Have also tried other names than "Var". Local/global doesn't help, 
neither does the "if( i == 1 ) Var = 0;" although it does indeed 
initialise "Var"??

Thanx in advance









------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/