jeudi 21 mai 2015

Endless JavaScript ELSE IF statement 650 Need shortening

I need to modify some script that runs in a program I use. The script ONLY plots horizontal lines at specific prices on a chart that has an X & Y axis. Whenever I switch to a new chart, the script will run through all the statements until it gets to the Symbol/name that matches the chart, then it will load the lines. I am using the never ending "if else statement" to make things as simple as possible for me. I have 650 if else statements, each contains hundreds of "addlines." There is no relation between Symbol Names, except the letters in the alphabet. All prices/numbers that the symbols contain are random. But I am looking for a better solution to make it run faster and more efficient instead of having 650 else if statements. I know the commands I used aren't the same I am just generalizing. I hope someone can help.

multiply the Else if statements by 650 and that's how many there are.

var Symbol
if (Symbol == "AAB") {
    addline(37.5);
    addline(40.9);
    addline(15.5);
    addline(100.5);
    etc....
}else if (Symbol == "ZOB") {
    addline(15.8);
    addline(20.9);
    addline(100.5);
    addline(200.5);
    etc....        
}else if (Symbol == "STX") {
    addline(10.9);
    addline(19.8);
    addline(5.5);
    addline(20.2);
    etc.... 
}else if (Symbol == "AXI") {
    addline(200);
    addline(20);
    addline(5.9);
    addline(9.9);
    etc.... 
   }else if (Symbol == "AXI") {
    ETC.....
    }    

   return;      

  }

Aucun commentaire:

Enregistrer un commentaire