And rather than using loops to find your object_id, use the .find() array function, its far quicker when you havelots of objects.
Type myObject
id
name as string
EndType
Global gMyObjects as myObject[]
for i=1 to 1001
CreateObjectBox(i, 10, 10, 10)
SetObjectPosition(i, random(0,500) - 250, random(0,500) - 250, random(0,500) - 250)
myobj as myObject
myobj.id=i
myobj.name="objectname"+Str(i)
gMyObjects.insert(myobj)
next
time# = timer()
for i=0 to 1000
if gMyObjects[i].id=1001
test1#=timer()-time#
exit
endif
next
time# = timer()
if gMyObjects.find(1001)
test2#=timer()-time#
endif
do
print(test1#)
print(test2#)
sync()
loop