Globals should be used sparingly, in my opinion, as they always exist for the entire duration of the program and are accessible to 100% of your code, which can make errors very hard to find.
The globals version would be:
type enemy
object as integer
x as integer
y as integer
z as integer
end type
enemy_return as enemy
dim enemy_array(10) as enemy
for n=1 to 10
make object cube n,1
newEnemy(n,1,2,3)
enemy_array(n)=enemy_return
next n
function newEnemy(object,x,y,z)
enemy_return.object = object
enemy_return.x = x
enemy_return.y = y
enemy_return.z = z
endfunction
The way it would be used would be something like:
type enemy
object as integer
x as integer
y as integer
z as integer
end type
dim enemy_array(10) as enemy
for n=1 to 10
make object cube n,1
enemy_array(n)=newEnemy(n,1,2,3)
next n
function newEnemy(object,x,y,z)
e as enemy <-- This is now local
e.object = object
e.x = x
e.y = y
e.z = z
endfunction e
This is just a simple example, it really isn't meant to do a lot.
This is just a neat and tidy way of programming, it's also a feature in every other language I have used. The problem with the globals route is that it is prone to programmer error, e.g. you could forget to call the function and assume the values in the global are correct.
Also, as the amount of functions increases, so does the amount of globals you need - and don't forget, they are always in memory even if you only use the function once in the whole program.