I've almost succeeded in coding what I wanted by declaring the column numbers and the layer numbers with datasets and then using the wcol command inside the function to define the range. This is an indirect way of passing an array of range variables inside the function. For example, if I wanted to plot columns 8 and 10 (X-axis is column 1), both in Layer 1:
Layers = {1, 1};
Columns = {8, 10};
PlotSingle(..., Layers, Columns....);
And the function becomes
function PlotSingle (..., dataset Layers, dataset Columns, ....)
{
.....
range rI = [%H]1!wcol(Columns[i]); // range variable
win -a %(uid2name(range2uid(["%(graphname$)"]))$); // activate the graph window
page.active = Layers[i]; // activate Layer i
layer.include(rI); // plot in the active layer
...
}
OK, now I have a second problem. I'm trying to modify Labels in the graphs via the function as well, so I need to pass the arguments successfully. I'm trying to do this with StringArrays but so far it's not working. For example, the label modification without the function would look like this:
if (exist(Text2,16)==16) Text2.text$ = r\-(lin)=$(rlin) %; // If the label exists, update it
if (exist(Text3,16)==16) Text3.text$ = J\-(ch,max,lin)=$(jmaxlin, .1) A/cm\+(2); // If the label exists, update it
if (exist(Text4,16)==16) Text4.text$ = P\-(ch,max,lin)=$(Pmaxlin, .1) W/cm\+(2); // If the label exists, update it
So basically just look if the labels exist and then update them.
Now for the modified version. The code inside the function looks like this:
function PlotSingle (..., StringArray LabelNames, StringArray LabelValues, ...) // Plot transfer curve
{
int LabelsNo = 3;
if (LabelsNo >= 1){
loop(i, 1, LabelsNo){
if (exist(%(LabelNames.GetAt(i)$),16)==16) %(LabelNames.GetAt(i)$).text$ = %(LabelValues.GetAt(i)$); // If the label exists, update it
};
};
And I'm calling it like this:
StringArray LabelNames = {"Text2", "Text3", "Text4"};
StringArray LabelValues = {r\-(lin)=$(rlin) %, J\-(ch,max,lin)=$(jmaxlin, .1) A/cm\+(2), P\-(ch,max,lin)=$(Pmaxlin, .1) W/cm\+(2)}; // Problem
PlotSingle(..., LabelNames, LabelValues, ...);
The problem exists in the StringArrays. I cannot pass them in the function. Any ideas as to what the mistake is?