|
|
Re: how to declare index variables in EOL [message #1849260 is a reply to message #1849259] |
Mon, 10 January 2022 14:08 |
fang yan Messages: 27 Registered: October 2020 |
Junior Member |
|
|
Hi Deimitris,
My intention is to declare a variable each time the while loop runs.
For example that the size is 3 (size_source=3), then the While runs 3 times, and each time, I am hoping to declare a variable source_j, thus after 3 runs, I will have 3 variables of source_0, source_1, and source_2.
The simplified code is as follows.
I know the codes are not correct, but I don't know the right way to declare.
var size_source=inference.source.size();
var j=0;
while(size_source>0)
{
var source_j: String;
source_j= inference.source.at(j).name.content;
j=j+1;
size_source= size_source-1;
}
Hope this explains better.
Thanks
Fang
|
|
|
Re: how to declare index variables in EOL [message #1849261 is a reply to message #1849260] |
Mon, 10 January 2022 14:20 |
|
Hi Fang,
You could do this using the code below but it's an ugly hack that I'd try to avoid if at all possible.
var frame = System.context.frameStack.topFrame;
for (i in 1.to(3)) {
frame.put((
new Native("org.eclipse.epsilon.eol.execute.context.Variable")).
createReadOnlyVariable("var_" + i, i));
}
var_1.println();
var_2.println();
var_3.println();
Best,
Dimitris
[Updated on: Mon, 10 January 2022 14:22] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03004 seconds