dim array#(13,4)

Blitz3D Forums/Blitz3D Programming/dim array#(13,4)

Ross C(Posted 2003) [#1]
Why does this work on some computers and not on others?? My friend reported this didn't work and gave an error saying "Entity doesn't exist"

The entity was stored in the array at every (x,0) position. Only thing i can think of is some computers don't like the pointer to the entity in memory to be a floating point number. But how do i store floats in beside entities then?


Stevie G(Posted 2003) [#2]
If it doesn't work like that I guess the only thing would be an array of types .. If you know this already apologies ..

type my_type
field blah#
field entity
end my_type

dim stuff.my_type(13,4)

for x=0 to 13
stuff(x,0) = new my_type
stuff(x,0)\blah = my_float
stuff(x,0)\entity = my_entity
next


Ross C(Posted 2003) [#3]
Yeah, thanks. Just seems odd that it works on some computers and not others. Thanks :)


sswift(Posted 2003) [#4]
You should never try to store a pointer in a floating point number. The reason it worked sometimes and not others is because the location chosen to store the entity in ram is not the same always. It's not even guaranteed to work on the same cumputer all the time. Floating point numbers do not store the exact number you put in, they store an approximation of it. A very large integer might be too large for it to reproduce accurately. Ie, if you put in 10 or 100, ot 10,000 it might return that number, but if you put in 1,734,248,282 it might not return that exact number, it might round off the last few digits to 0.


MadJack(Posted 2003) [#5]
Ross C

sswift's nailed it I think - I made this mistake as well - storing pointers along with floating point numbers in the same array. Interestingly it worked fine with W95 but fell over when I upgraded to W2000.


Stickman(Posted 2003) [#6]
I dont know if this would help,
Try storing you large floating point numbers as a string ($) value.
I had a simaller problum when trying to store floating point values taken from a Direct X file with a pointer to a mesh as for DX stores floates something like this ( 1.005689-E.001) and the pointers were just 1,2,3,etc.

Like sswift said,a lot of times the returning value read from the array was different,confussing and blew my mind,So I fixed this by just storing the value into the array as a String value and my troubles were over.Not that string values are the best way of doing things but at least the values that were origanally loaded when reread from the array were constant now.


Ross C(Posted 2003) [#7]
Hey, thanks guys :)

I'm just using a different array for storing the entities, and another for their properties. Thanks for the stuggestion Stickman :o)


sswift(Posted 2003) [#8]
If I was your boss, and you programmed for me, and I found out you were converting pointers to floating point values and then sotring them in arrays as strings, I'd whip you like a redheaded stepchild. :-)


Not Available(Posted 2003) [#9]
LOL sswift ;)


Ross C(Posted 2003) [#10]
Hehe, i was using the array for storing the entity and it's variables. such as array pos(0,0)=entity (0,1)=x (0,2)=y (0,3)=z etc etc

So i wasn't really converting them willingfully :)