- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » loop script error
Page Start Prev 1 Next End
loop script error
loop script error
Mar-10-15 17:53:04
I want to understand for loop. I run this script with runScript("test.mos")
result of this script
"0
100
"
I am excepting 0- thru 100 count. Wht only start and stop value print screen?
Oki
test.mos
Code:
j:=0;
for i in 1:100 loop
j:=j+1;
end for;
j;
Re: loop script error
Mar-10-15 18:00:15
The result of a for-loop is nothing (a void value). If you want to print all values, you can use print(String(j)), writeFile, etc (note that print prints to stdout, not OMShell). Or construct the entire array.
For example using a for-reduction:
Code:
{i for i in 1:100}
Or as such:
Code:
j:=fill(0,100);for i in 1:100 loop j[i]:=i; end for;j
- sjoelund.se
- 1700 Posts
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » loop script error
There are 0 guests and 0 other users also viewing this topic