Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to return all array values in alert() message /w AE script?!

Explorer ,
Oct 29, 2014 Oct 29, 2014

Here's my code:

{

var selectedItem = app.project.activeItem;

var thisProj = app.project;

var layerList = new Array();

var compList = new Array();

function listLayers(compNum){

  for(i=1;i<=compNum.numLayers;i++){

  layerList.push(compNum.layer(i).name);

  }

}

function listComps(){

  for(i=1;i<=thisProj.numItems;i++){

        if(thisProj.item(i) instanceof CompItem){

        compList.push(thisProj.item(i).name);

        if(thisProj.item(i).numLayers>0){

        listLayers(thisProj.item(i));

        }

        }

  }

}

listComps();

alert("here's a list of all comp names:" + compList);

}

When I run it with ExtendScript Tool inside AE, the alert() causes this Error message:

invalid numeric result (divide by zero?)

It works fine if I only write out one of the items in the array. E.g.:

alert("blablabla"+complist[1];

Or if I leave out the '+'.

How can I write out the array or even multiple arrays in the same alert() and adding text in between?

Thanks in advance,

Fynn

TOPICS
Scripting
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 29, 2014 Oct 29, 2014

Try it this way:

alert("here's a list of all comp names:" + compList.toString());



Dan

Translate
Community Expert ,
Oct 29, 2014 Oct 29, 2014

Try it this way:

alert("here's a list of all comp names:" + compList.toString());



Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2014 Nov 05, 2014
LATEST

thank you for being so quick and sorry for taking so long.

and yup - that did the trick. thanks a lot!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines