Sunday, 15 January 2012

google apps script - How to use an array value as a variable name? -



google apps script - How to use an array value as a variable name? -

i have piece of script here creates object constructor, buildlist() takes info spreadsheet , spits out array containing section names. i'm trying in buildobjects() utilize array create object each section , fill various values pertaining department. i'm having problem line var adcnames[i] = new adc(adcnames[i]);

function adc(name) { this.name = name; } function buildobjects () { var adcnames = buildlist('adc', 1); var adcarray = []; (var in adcnames) { var adcnames[i] = new adc(adcnames[i][0]); adcarray.push(<<the variable created>>); } homecoming adcarray; }

i'm new using objects there may simpler way i'm missing. help appreciated.

all have rename variable.

try

function buildobjects () { var adcnames = buildlist('adc', 1); var adcarray = []; (var in adcnames) { var tempadc = new adc(adcnames[i][0]); //do whatever else need object. adcarray.push(tempadc); } homecoming adcarray; }

google-apps-script

No comments:

Post a Comment