I'm trying to create a toggle button on my chart to allow or dis-allow code processing. But I can't get it to toggle.
PHP Code:
debugClear();
var flg = Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM| Text.FRAME | Text.ONTOP ;
ButtonTitle = "Enable"
backcolor = Color.yellow;
forcolor = Color.blue;
ButtonPressed=null;
enable = false;
function preMain(){
setPriceStudy(true);
}
function toggle(){
Alert.playSound("click.wav");
if ( ButtonPressed == BUTTON_LEFT) {
if (ButtonTitle = "Disable"){
ButtonTitle = "Enable";
enable=false;
} else if(ButtonTitle = "Enable"){ // current state is disabled
ButtonTitle = "Disable";
enable=true;
}
drawTextPixel( 10, 10, ButtonTitle, forcolor, backcolor, flg, "Arial", 14, "btn");
}
return;
}
function main(){
drawTextPixel( 10, 10, ButtonTitle+"@URL=EFS:toggle", forcolor, backcolor, flg, "Arial", 14, "btn");
if (enable == false) return; // don't execute any code
/*
do a bunch of stuff
*/
return;
}
Comment