0 Replies Latest reply on Oct 8, 2009 3:34 AM by Loic.Aigon

    [JS] Eval problem with scriptUI

    Loic.Aigon Adobe Community Professional

      Hello,

       

      I want to build an scriptUI Interface with a specific group of buttons.

      This group will be repeated accordingly to a an external txt file (telling the script how many groups are needed).

       

      My script uses a for loop in the dialog construction like this :

      for(i=0; i<n; i++)
      {
           //Repeat the group of buttons with i as an ID;
           eval(addBtn(i));
      }
      
      

       

      to get the construction of the button, I created a addBtn(btnId) function.

      It returns the code string to create my group of buttons with i as an ID.

       

      function addBtn(btnId)
          {      
              myBtnString = "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=" = rapidDlg.add('group',undefined); ";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".alignment = ['left',' '];";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".checkBoxItem = rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".add('checkbox',undefined,undefined);";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".aFile = rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".add('button',undefined,\'a File\');";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".aFile.size= [245,20];";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".removeItem = rapidDlg.Group";    
              myBtnString+=String(btnId);
              myBtnString+=".add('button',undefined,\'-\');";
              myBtnString+= "rapidDlg.Group";
              myBtnString+=String(btnId);
              myBtnString+=".removeItem.size= [30,20];";
              
              return myBtnString;
          }
      

       

      But my loop doesn't seem to wok, and as the dialog appears, my groups are not created :-(

       

      Am i wrong using eval() or do I misuse it ?

       

      Thanks a lot for your help :-)

       

      Regards,

       

      Loic

       

      Attached the fulle script