9 Replies Latest reply on May 8, 2008 7:01 PM by (vkramji)

    [JS CS3] Variable Function Name

    Level 1
      Hello everyone,

      Does anyone know if you can put a variable into a function name?

      Bellow is a function that I am working on to avoid using an if statement with 33 possiblilites. It does work but I get a "undefined is not an object error".

      function myFunction(){
      var myDoc = app.activeDocument;
      var myRootXMLElement = myDoc.xmlElements.item(0);
      var myData = myRootXMLElement.xmlElements.item("xyzTag");
      for (b = 2; b <= 34; b++){
      if(b = myData.contents){
      myNewFunction = "my"+b+"VariableFunction()";
      try{
      eval(myNewFunction);
      }catch(e){
      alert(e);
      }}}}

      Because this physically does what I intend it to do I believe this should work but I can't get past this error. Could someone please let me know if there is a way to make this error free?

      Regards,
      Brett