Quantcast
Channel: COMSOL Forum: Most Active Discussions
Viewing all articles
Browse latest Browse all 5675

Application Builder, Newbie help, using For loop

$
0
0
Hi

I have just started out using the API for the first time and I wish to generate a number of Global Parameters entries, namely sigma_ink1, sigma_ink2, sigma_ink3 etc.

I have successfully recorded a Method using the Set operation and surrounded it with a For block statement ...

int n=10;
for (int i=0; i<n; ++i) {
int j=i+1
with (model.param());
set("sigma_ink"+j, "1000[S/m]");
endwith();
}

but instead of using 'n' I want to use a defined Global parameter 'ArraySize' which = 10 (or whatever the user enters).

Question: What is the syntax for using ArraySize instead of 'n'?

I have tried...

for (int i=0; i<"ArraySize"; ++i)

...but this just gives an error and I have searched but not found an answer.

Any newbie help much appreciated
Colin

Viewing all articles
Browse latest Browse all 5675

Latest Images

Trending Articles



Latest Images