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

Multidimensional Array in Indesign?

Participant ,
Jan 07, 2015 Jan 07, 2015

Hey guys,

normally in javascript I can just create a multidimensional array like so:

myArray = [ [] ];

and then assign values like this:

myArray[0][0] = 'item1';

In extendscript I get the error "undefined is not an object". Is there something I forgot about, or is this just not possible in Indesign?

TOPICS
Scripting
1.8K
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

Participant , Jan 07, 2015 Jan 07, 2015

I found out it was another problem. The code works like this, but you need to define in the beginning how many arrays are in the array. Otherwise it will throw the "undefined" error.

points = new Array(object.paths.length);

for(i = 0 ; i<object.paths.length; i++){

    points = new Array();

}

This code works now, as the length of the array is exactly the length you need. And for every key you add another array, to create your two dimensional array on every key.

Translate
Community Beginner ,
Jan 07, 2015 Jan 07, 2015

Hi Stamm,

Try below code:

var myArray = [[,]];

myArray[0][0] = 'item1';

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
Participant ,
Jan 07, 2015 Jan 07, 2015
LATEST

I found out it was another problem. The code works like this, but you need to define in the beginning how many arrays are in the array. Otherwise it will throw the "undefined" error.

points = new Array(object.paths.length);

for(i = 0 ; i<object.paths.length; i++){

    points = new Array();

}

This code works now, as the length of the array is exactly the length you need. And for every key you add another array, to create your two dimensional array on every key.

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