Announcement

Collapse
No announcement yet.

Can I force formula Output to redraw before EFS finishes?

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

  • Can I force formula Output to redraw before EFS finishes?

    I've always noticed that the formula output window never re-draws properly until the current iteration of a script returns. This has never really been an issue but now I have a script that runs for some time and I'd like to put a message in the output window that its running but that message never shows up until it is finished. Is there a way to force the output window to re-draw properly while the script is executing?

  • #2
    Hello ebr,

    While a formula is processing on bar 0, any debugPrintln() statements should be printed to the window as those calls get executed. Any debugPrintln calls that occur on the historical bars while the formula is initially loading cannot be viewed until the formula has completed loading. I'm not positive, but I think that is probably an intentional behavior. Forcing the formula output window to refresh after each historical bar is processed could potentially increase the load time for formulas, which would be undesirable.

    Please let me know if I've misunderstood your question.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      I think you understood the question fine, but I don't think eSignal is behaving exactly as you described.

      I have a formula that, when a button is pressed, does its own processing on each bar within the chart. However, as far as eSignal is concerned, the formula is completely loaded and on bar 0. Even so, the Formula output window is not re-drawn properly until after the formula completes.

      I say "not redrawn properly" because what happens is this:

      When I issue a debugPrintln() statement before launching my long script, the formula output window appears to register this but, instead of printing what I issued in the debugPrintln statement, the last line written to the formula output window prior to this time is duplicated and then it freezes up until the formula completes and then the output is re-drawn correctly.

      I have noticed this behaviour since I started using eSignal several years ago so it is not something new. This is just the first time where I have a script that is long enough for it to really matter much.

      Comment


      • #4
        -

        Hello ebr,

        I think what we may be dealing with is that the formula output window is simply not able to graphically refresh fast enough to keep up with the speed of the processing.

        With your button process, if you are using a loop to perform the processing and not reloadEFS(), you could try adding in a while loop that iterates for a number of times or period of time between each bar's processing so that you can physically see each print. I haven't tried this myself, but that is the only idea I can think of to accomplish this. There isn't any built-in functionality to force the window to be redrawn after each bar's processing.

        However, I'm unsure as to why you need to do this versus scrolling down through the formula output window to view the historical prints after the processing has completed. When I'm debugging formulas and need to see historical bar data printed to the formula output window I incorporate the current bar's index with each print so that I know which bar each print corresponds to. If you can describe in more detail what you are trying to accomplish I may be able to provide some alternative suggestions.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Thanks for the help, Jason.

          Its not an issue of just not being able to see information. Its definitely an issue of the output window not redrawing properly until the script is completely finished.

          I'm trying to use the output window as a vehicle to inform the user that something is happening. My process will take a little over two minutes to complete so I'm trying to put up a simple message that its working and will finish in a couple minutes (so it doesn't look like everything has just frozen). But, this message never makes it to the output window until the process has actually finished.

          It looks like a bug (or deficiency) because the output window appears to try to put up my message, but it gets mucked up in the process.

          I'll throw together an example and post it so you can see just what I'm talking about.

          Comment


          • #6
            Okay - here's a quick example that shows exactly what I'm talking about. Function puts up a button that, when pressed, loops for 10 seconds.

            Here's the code:

            Code:
            function preMain() {
                setPriceStudy(true);
                setStudyTitle("Output Test");
            
            }
            
            function main() {
            
                //put some info in debugOutput to show redraw problem
                if (getBarState() == BARSTATE_ALLBARS) {
                    debugClear();
                    debugPrintln("This is a line of text.")
                    debugPrintln("");
                    debugPrintln("This line will appear to repeat when the test function tries to output");
                }
            
            
                //draw our button
            
                drawTextAbsolute(2,125," Start Process @URL=EFS:test",Color.black,null,Text.RELATIVETOBOTTOM | Text.BUTTON|Text.VCENTER,"Arial",10,"mngStop");
                
                return;
            }
            
            function test() {
            var start = new Date;
            var now = new Date;
            var x = 0;
            
                debugPrintln("Starting Process...");
                while ((now.getTime() - start.getTime()) < 10000) {
                    now = new Date;
                    x = 100 * 5 / 4 / .00876;  //no op
                    x = 100 * .5 / 4005 / .00876;  //no op
                }
                
                debugPrintln("Done.");
            }
            And here's what happens in the output window:

            First, when we load the function:



            Then, right after pressing the button (while the script is running):



            And, finally, when the script finishes:



            Notice how the output window tries to print my "Starting" message but, instead, just repeats the last line written to the output window...? But, when the process finishes, the output is re-drawn properly (no repeat message). So, its some sort of re-draw issue.

            Like I said, I've always noticed this. This is just the first time it really mattered.

            Thanks again for the help. I've attached the actual function so you can see on your system.
            Attached Files

            Comment


            • #7
              Hello ebr,

              Thank you for posting the code example. I can see that you're trying to use the formula output window as a progress bar of sorts. I do see the behavior you're describing. Unfortunately, that window was not intended to be used in this way. I can't file a bug report on this one because I don't see this as a bug. Forcing the formula output window to redraw after each execution of the formula or a loop that is executing during each of those executions would potentially add a great deal of lag for the loading process of formulas in general. This would not be a desirable behavior for most users. I doubt that development would want to make such a change, but feel free to submit a request to [email protected].

              Plotted indicators and drawn objects on the chart also do not display until the initial loading process has completed. Only the final result gets displayed. Same goes for a loop that would be printing information to the output window or a text label that was being updated on each iteration of the loop.

              I can't think of any alternative solutions for a progress routine at this time.
              Jason K.
              Project Manager
              eSignal - an Interactive Data company

              EFS KnowledgeBase
              JavaScript for EFS Video Series
              EFS Beginner Tutorial Series
              EFS Glossary
              Custom EFS Development Policy

              New User Orientation

              Comment


              • #8
                I'm new to EFS so don't know pitfalls, but if this is important you might consider the progress display being external to eSignal:

                1) use the dll interface and write code to send messages to a small external app that displays the progress.
                2) use the file object and write a scratch file that is polled by an external app.

                As I say, don't know the pitfalls, and not ideal.

                Good luck

                Comment


                • #9
                  Thanks for the help anyway, Jason.

                  Dave - this isn't really that important. I don't really have to know the progress - just wanted to throw a message up that something was happening because, otherwise, it looks a lot like eSignal is hung.

                  I have an idea of how to get around it but its really not a big deal - just wanted to get it to work if I could. Thanks again.

                  Comment

                  Working...
                  X