Arrays are a good way to hold tables of data internally in your scripts but they can be hard to debug as the numeric index gives no clue as to the context of a particular value.
The advantage of a language like C#script or VBscript is that it allows you to define Key Value Pairs - which are like 2D arrays but use names rather than numbers for the index.
//Create objects to hold the key value pairs
var R1fields = new ActiveXObject("Scripting.Dictionary");
var R2fields = new ActiveXObject("Scripting.Dictionary");
//Create objects to hold the key value pairs
R1fields["Add"]("Results Directory", "Run settings,PathString");
R2fields["Add"]("Results Directory", "Input Sources,outputPath");
R1fields["Add"]("Equity TRI", "Run settings,CheckBox13");
R2fields["Add"]("Equity TRI", "Asset Settings,Equity TRI");
//The key value pairs for R1 give us an Excel sheet name
//and ActiveX field name for the supplied variable name svName
var R1Sheet = GetCSVItem(R1fields(svName), 0);
var R1Field = GetCSVItem(R1fields["Item"](svName), 1);
//The key value pairs for R2 give us a tab name
//and field name for the supplied variable name svName
var R2Tab = GetCSVItem(R2fields(svName), 0);
var R2Field = GetCSVItem(R2fields["Item"](svName), 1);
The example shows part of a testing project where an Excel based application, R1, was being replaced with a Windows desktop application, R2.
Various input fields were duplicated across both versions and the existing (manual) tests for R1 had specific names for the inputs. For R1 the input fields were ActiveX components in particular sheets, whereas the corresponding fields in R2 were Windows Forms fields on tabbed pages.
I could have defined an array containing R1 sheet and field and R2 tab and field values for each input but with potentially dozens to accomodate, the scripts would have been unreadable if they relied on numeric indices.
The solution was to use C#'s Key Value Pair construct to allow the established variable names to be used to reference the corresponding input fields in both R1 and R2. I extended the principle by allowing the keyed value to contain a CSV rather than just a plain string (to allow for R2 input fields contained within groups).