When you load an object like this: obj = LoadObject( "media\guy.bmp" ). A specific slot from memory is reserved for the object. The variable "obj" itself points to that memory. That's why you can do this:
Code: Select all
obj = LoadObject( "media\guy.bmp" )
something = obj
MoveObject something, 5
Because "something" and "obj" are basically the same thing. A seemingly random number if you print it out.
Let's say the variable "obj" has a value 1234. This means that you can control this object by using the number, which actually is the objects position in memory. Like this:
Code: Select all
obj = LoadObject( "media\guy.bmp" ) //obj is now 1234.
MoveObject 1234, 5
This means that when you move an object by using a number, you (accidentally maybe) point to the memory slot the object is in. If you use any other memory slot, it results to MAV.
Maybe all the objects in Coolbasic have always been assigned with a number from the beginning of the memory (e.g. 1, 2), and I just haven't realized it. Nevertheless, if you load an object and then give a command to move an object in memory slot 1, most likely the object you loaded will move. So there actually is no bug, and the loop-failure was because of my own noobness:
Code: Select all
For i = 5 To 6
//first round, i = 5
i = LoadObject( "media\guy.bmp" ) 'reserved to mem slot 1.
//so now i = 1
//next round i is obviously 2 etc...
Next i
So actual numbers (in code) don't have anything to do with variable names OR the place in memory where the object is loaded. It just happens to be 1 with objects and something around 10,6 million with images.
Edit. Although I read what Jare said, I still wrote almost the exact same thing without realizing it. Probably to put things straight with myself or something...
I blame the language barrier!