Announcement

Collapse
No announcement yet.

Why does initLib() get called 4 times?

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

  • Why does initLib() get called 4 times?

    Can any one explain why initLIb() function would get called 4 times?
    PHP Code:
    function initLib()
    {
        
    debugPrintln("Function: initLib entered.");
        
    bUserInit false;
        
    //build Trace file name and set the TraceFile object
        
    TraceFileName SUBJECT " " getSymbol() + "(" getInterval() + ") Trace.txt"
        
    TraceFile = new File(TraceFileName);
        
    TraceFile.open("wt");
        
    Trace("Trace file: " TraceFileName " - opened.");

    The debugPrintln() appears 4 times in the formula output window. The obiouse explaination is that the addLibrary() is being called 4 times. But that line of code
    PHP Code:
    var TMLib addLibrary("TMFunctions.efsLib"); 
    But that line of code is located at the top of my program, above the preMain() function.

  • #2
    hi scjohn,

    I was able to get it called multiple times only when starting up. ie, saving a page with a formula that had an addLibrary.

    1st is on the deserialization from the file, but before the symbol has been set, this is a syntax check call.

    2nd is when the deserialization was finished, and the symbol has been set, the initial data request call.

    3rd and 4th were because I had a checkVersion statement in the EFS, so it d/led the latest from the website, ran it once, then ran my current version again, to determine the version for comparison.

    So... on startup, you should experience a call to initLib twice.. If you just do an right-click add formula after eSignal has started up, it should just show up once.

    Let me know if you're seeing your 4 debug statements in a different scenario, and I can check it out for you.

    Thanks!

    Comment


    • #3
      I removed and then added back the indicator. I got 4 debug statements. I then Reloaded the indicator and I got 4 debug statements.

      Comment


      • #4
        Weird, can you email me your EFS and EFSLib? dloy [at ] mail.esignal.com

        Thanks!

        Comment


        • #5
          email sent

          Comment


          • #6
            Hi John,

            This is what's happening. Every time there is an efsExternal() or efsInternal() call (or actually any time that a call is made to a builtin study on another symbol or interval), the main EFS has to stop execution, and queue a delayed execution. The engine then goes ahead and executes the called efs or efsInternal, or other symbol/interval FIRST, and then re-executes the original main EFS.

            This is the only way in which we can manage the dependencies... as the main EFS depends on those other calls. This also includes the initLib calls as users may have dependencies in the initLib function that need the newly calculated data.

            ie in the example you sent me, initLib was called twice as one efsInternal call was made. In your full script you probably have 3 efsInternal or efs or other symbol/interval calls, in which case your initLib would be called once each for the dependencies, and once more for the main EFS.

            Hope this helps!

            Comment

            Working...
            X