Announcement

Collapse
No announcement yet.

Do only once

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do only once

    I have the following code written that is supposed to use the boolean variable (bInit) to do some things only once, each time the EFS starts up.
    However, when I run this, the EFS never executes the "if (bInit == false)" routine. If it did, then it would post the messsage "Initialization Done" to the Alert window.

    Can someone please help me figure out what I have wrong here, and why this "if (bInit == false)" routine never executes?

    Thnx

    var bInit = false;

    function preMain() {
    setPriceStudy(false);
    bInit = false;
    }

    function main() {

    if(bInit == false) { // Only do this loop the very first time this is ever loaded.
    bInit = true;
    Alert.addToList("X", "Initialization Done", Color.red, Color.green );
    }


    Alert.addToList("Z", "tick", Color.black, Color.black );


    return;

    }
    Last edited by fish7; 01-08-2007, 06:50 PM.

  • #2
    John
    Your initialization routine is working fine. You can verify this by adding a debugPrintln(bInit) statement before and after setting bInit to true in the routine
    The reason the alert is not triggered inside the initialization routine is because the alerts are triggered only on bar index 0
    Alex

    Comment


    • #3
      Thnx for the sanity-check, Alex.

      That makes sense.

      JOHN

      Comment


      • #4
        John
        My pleasure
        Alex

        Comment

        Working...
        X