Announcement

Collapse
No announcement yet.

Real Buttons...

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

  • Real Buttons...

    I have a dilema...

    All of the recent posting about buttons got me back thinking about my favorite subject, buttons.

    I want to make a button by calling

    drawButtons();

    in main()

    function drawButtons(){
    drawTextPixel(1, yHt, "34EMA "+ema34+"@URL=EFS:ema34OnOff", Color.blue, Color.red, Text.BUTTON|Text.RELATIVETOLEFT|Text.RELATIVETOBOT TOM, "Courier", 10, 10)
    }

    which calls ema34OnOff(), which sets a flag, ema34 to on or off and then redraws the button

    function ema34OnOff(){
    if(ema34=="On"){ema34="Off";}
    else{ema34="On";}
    drawButtons();
    }

    and then redraws the button

    Then in main I either draw the ema or not...

    if(ema34=="Yes) return vEMA;
    return;

    but for some reason the var ema34 is not making it out of the ema34OnOff function back to main.

    var vEMA = new MAStudy(34, 0, "HLC/3", MAStudy.EXPONENTIAL);

    What am I missing?

  • #2
    Potential solution..

    if your code, you have to create and maintain the control variables for your system.

    The example below should help.

    B


    var vEMA = new MAStudy(34, 0, "HLC/3", MAStudy.EXPONENTIAL);
    var ema34 = true;

    function main()
    {

    //... other code...

    drawButtons()

    if(ema34) { return vEMA; } else
    { return; }

    }

    function drawButtons(){
    drawTextPixel(1, yHt, "34EMA "+ema34+"@URL=EFS:ema34OnOff", Color.blue, Color.red, Text.BUTTON|Text.RELATIVETOLEFT|Text.RELATIVETOBOT TOM, "Courier", 10, 10)
    }


    function ema34OnOff(){
    if(ema34){ema34=false;}
    else{ema34=true;}
    drawButtons();
    }
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Maybe it is just a typo in your post. You are missing a " in the statement if(ema34=="Yes) return vEMA; I've noticed that with JavaScript errors don't always show up where the problem is located.

      Comment


      • #4
        Thanks Brad, I was doing what you suggested but my code is so long I had forgotten I was using Yes/No not On/Off for the value of ema34, doh...

        Anyway, I am able to change the value of ema34 with the button, but what I am trying to do is remove the 34ema from the chart, so I think I need to use the dreaded

        reloadEFS()

        I have a reload occur after I change the ema34 value from Yes to No, and debugPrint confirms it, but as soon as the reload starts, the value goes back to the default Yes. Does


        var fp1 = new FunctionParameter("ema34", FunctionParameter.STRING);
        fp1.setName("Display 34ema");
        fp1.addOption("Yes"); fp1.addOption("No"); fp1.setDefault("Yes");

        have anything to do with that?

        Comment


        • #5
          Dave,

          I am doing an extract on my code of the routine I use to save the present values as the new default values for the edit menus, if that would help. planning on posting tomorrow. The problem is I keep getting errors. It works where I have it in the original program... It is late though. from what u are saying it sounds like it would help.

          Regards,

          Comment

          Working...
          X