Announcement

Collapse
No announcement yet.

internal functions

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

  • internal functions

    Hi,

    I have an internal function outside of main(), which is called getString(i). I put a debugPrintln statement inside getStrong and found that this function is called from bar 1 to the current bar, in my case, it's 2846. But in my main(), the internal function should only be called when bar count is 2840 or above. I thought what's outside the main(), i.e. internal functions, are not executed by the interpreter. So, why do I get a print statment from within getString from all the bars? I dont' understand.

    William




    PHP Code:
    main()
    {
         
    //some code here


        
    if (getCurrentBarCount()>=2840
        {
            
    returnstring efsinternal("getString"22 );
        }


         
    //some code here


    }

    function 
    getString(i

      var 
    ret "";
      var 
    ch=0;
      var 
    x=0;
      
    debugPrintln("inside getString" +" BarCount = "+getCurrentBarCount());
      for (
    x=0x<ix++) 
        {
            
    ch d.call("JSgetS");
            
    debugPrintln("ch = "+ch);
            if (
    ch>=0
            {
               
    ret ret+String.fromCharCode(ch);
            }
        }
        return 
    ret;


  • #2
    If you call it as a function using getString(22) instead of using efsInternal() you will get the desired result. When you use efsInternal() you are essentially creating a stream object and it will initialize using all available bars the very first time it is called.

    Chris

    Comment


    • #3
      I see. Thank you for the clarification, Chris.

      William

      Comment

      Working...
      X