Announcement

Collapse
No announcement yet.

Buttons not working

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

  • Buttons not working

    Hi,
    I have some buttons I copied from some example ESF code which work fine in a small test ESF program. I copied the same code into a large ESF program (to big to post). It displays the buttons but when I click on them, nothing happens. I put in some debugPrintln statements in the button click code to see if it gets executed, nothing gets displayed.

    Any ideas of why they may not work?

    So then I thought I would just keep the buttons in a separate esf and pass the information in GLOBAL variables. That works, but all my esf programs in other charts have access to the global variables. So I added a prefix to the global variable in the sending esf and then parse it in the receiving esf so I know which chart the globlal variables are for.

    This works, but is there a better way?

    Thanks
    Tom

  • #2
    Hi Tom,
    Originally posted by windswepttom
    Hi,
    I have some buttons I copied from some example ESF code which work fine in a small test ESF program. I copied the same code into a large ESF program (to big to post). It displays the buttons but when I click on them, nothing happens. I put in some debugPrintln statements in the button click code to see if it gets executed, nothing gets displayed.

    Any ideas of why they may not work?
    I would like to try and help you on this, but your question is too vague.


    So then I thought I would just keep the buttons in a separate esf and pass the information in GLOBAL variables. That works, but all my esf programs in other charts have access to the global variables. So I added a prefix to the global variable in the sending esf and then parse it in the receiving esf so I know which chart the globlal variables are for.

    This works, but is there a better way?
    You appear to have transitioned from executing a function in your first question, to passing global variables and determining their source in this one. While you seem to know what you are doing, it isn't evident what you are trying to accomplish (to indicate if there is a better way).

    I recommend that you take some extra time to post a working example(s) of your code. That will not only clear things up, it also will allow more forum members to help, since I doubt most have the extra time to re-create examples from your description(s)

    Comment


    • #3
      Hi Steve,
      Sorry about being vague, but I've tried to make up some small esf examples with some of the same code as the large esf, and they all work. So it is hard for me to be specific, because I have no idea why it works in a small esf and not my large one.

      I was hoping someone had some general rules like: the location needs to be in the "main function" at the start or end or check for isLastBarOnChart. Or someone had the same problem because they where using some function which is does not work with buttons. It was a shot in the dark.

      I'll keep trying to get an example that does not work and will post it when/if I get it. I'll also try adding more code to my working button esf from my large esf untill if find the problem.

      As for my second question about global variables, I was hoping for a global variable local to the current chart or a way to pass variables between two esf s on the same chart.

      In the future, I'll keep my post to one question per post and try to post an example.

      Thank you for your response.
      Tom

      Comment


      • #4
        Hi Tom,

        The size of the efs doesn't have anything to do with any problems you may be having, I can say that definitely. There are several examples in the Functions Fileshare (link below) that may help in the buttons,Global and Trend Line folders may provide some assistance, as will the associated sections in the Knowledgebase (link below).

        Comment


        • #5
          Hi Tom,

          Steve is right, size of efs is a dont care. I have over 5k lines and mine work fine.
          Here is how I do it:
          a/ I declare, in main, my buttons at "ALLBARS" time, same place I declare my studies [therefore once],
          b/ I have all the "EventHandlers" [which manage the buttons] as independent fucntions, after main.

          Look some more, you will find the problem.
          Good Luck!

          Mihai
          Mihai Buta

          Comment


          • #6
            Hi Mbuta,
            I tried your suggestion of using "ALLBARS" and my eventhandlers were already independent functions, did not help.

            I also copied Steve's functions from his "Up-n-Down_Arrows" to see if my program recognized a double-click, nothing happened.

            It looks like my esf does not get any click event.

            For now, I give up. I have something else to do. By putting the buttons in a separate esf and passing the results through global variables works.

            Thanks for your suggestion.

            Tom

            PS. And I thought my esf was large with 2.5k lines, lol

            Comment


            • #7
              Tom,

              Where are you placing the up and down Arrow functions in your efs? I trust they are outside function main() and any other function.

              Comment


              • #8
                Hi Steve,
                Yes they are outside the main funtion and any other
                Tom

                Comment


                • #9
                  Tom,

                  It sounds like there may be errors in your code such that the functions are never processed. I have several ideas.

                  The first is to place debugPrintln statements before and after the functions. If they do not output to the Formula Output window, there is an error previous to these that are preventing the functions from being processed. The second is to place the functions at the very beginning of the efs. third, have you set it up correctly? Finally, have you performed a syntax check.

                  Based on your descriptions to date, there appears to be something in your code. Hope this helps you out in some way.

                  Comment


                  • #10
                    Hi Steve,

                    I take that back, somehow the "}" for main() got moved to the end of the esf. So all functions were in the main() function.

                    I'm surprised that is the only thing that did not work!

                    Now I got some of "ReferenceError" messages to work through.

                    Thank you very much for your help

                    Tom

                    Comment


                    • #11
                      Hi Tom,

                      You are most welcome. I am glad I could help you figure that out. You bring up an important point though.

                      Functions that are nested within functions are entirely legal. However, their scope is limited (i.e. local) within the containing functions scope.

                      This explains why the other functions worked when called within the local scope of main() and also explains why the button click (a global event) could not call the function that was in the local scope of the main() function.

                      Originally posted by windswepttom


                      I take that back, somehow the "}" for main() got moved to the end of the esf. So all functions were in the main() function.

                      I'm surprised that is the only thing that did not work!

                      Comment


                      • #12
                        Tom,

                        I've been following this post all day, as I receive emails via a subscription to the forum.

                        I know how busy Steve and other active members are and it's great that he generously offerrred and was able to help you out.

                        However, as was requested several times, it's a common practice to post the problematic code, both as an efficient means of getting your problem solved as quickly as possible, and as a common curteousy to those offering their help.

                        It's unfair to have people debugging a simple syntax error in the dark, and apparently again asking for further assistance, code yet to be seen by anyone.

                        If your code is so proprietary, then as Alexis mentioned earlier there are consultants available. If not post it, it's unfair to have it both ways?
                        Glen Demarco
                        [email protected]

                        Comment

                        Working...
                        X