Page 1 of 1
Please tell me whats wrong.
Posted: Sun Oct 16, 2011 8:28 am
by andenixa
Got a simple snippet:
Code: Select all
var d := dictionary;
for i := 1 to 3
d[i] := "test";
endfor
print(d);
Output: dict{ 4 -> "test" }
PS: core099
Re: Please tell me whats wrong.
Posted: Sun Oct 16, 2011 8:50 am
by Austin
Good question... I did some tests with Runecl.exe and produced the following:
Code: Select all
use os;
program TestScript()
var d := dictionary;
for i := 1 to 3
d[i] := "test";
Print("i="+i+" Val="+d[i]);
endfor
print(d);
return 1;
endprogram
-------------------
i=1 Val=test
i=2 Val=test
i=3 Val=test
dict{ 4 -> "test" }
Code: Select all
use os;
program TestScript()
var d := dictionary;
for i := 1 to 4
d[Hex(i)] := "test";
Print("i="+i+" Val="+d[Hex(i)]);
endfor
print(d);
return 1;
endprogram
-------------------
i=1 Val=test
i=2 Val=test
i=3 Val=test
i=4 Val=test
dict{ "0x1" -> "test", "0x2" -> "test", "0x3" -> "test", "0x4" -> "test" }
Code: Select all
use os;
program TestScript()
var d := dictionary;
for i:=1 to 4
d[CStr(i)] := "test";
Print("i="+i+" Val="+d[CStr(i)]);
endfor
print(d);
return 1;
endprogram
-----------------------
i=1 Val=test
i=2 Val=test
i=3 Val=test
i=4 Val=test
dict{ "1" -> "test", "2" -> "test", "3" -> "test", "4" -> "test" }
Code: Select all
use os;
program TestScript()
var d := dictionary;
var i;
for ( i := 1; i <= 4; i += 1 )
d[i] := "test";
Print("i="+i+" Val="+d[i]);
endfor
print(d);
return 1;
endprogram
----------------
i=1 Val=test
i=2 Val=test
i=3 Val=test
i=4 Val=test
dict{ 1 -> "test", 2 -> "test", 3 -> "test", 4 -> "test" }
Re: Please tell me whats wrong.
Posted: Sun Oct 16, 2011 9:02 am
by andenixa
Thanks a lot Austin.
It seems that a
for shortcut ain't reliable. Thats too bad because I used it so frequently...
The other glitch I found is looping from "uninit" would create an infinite loop ending with a crash.
like:
Code: Select all
var t;
for i := t to 4
// pass
endfor