Function that returns a type

Blitz3D Forums/Blitz3D Programming/Function that returns a type

Local Mesh=CreateMesh()
Local Piv=CreatePivot()
Local Sprite=CreateSprite()
Global Cam=CreateCamera()


Mesh,Piv, and Sprite are Local Variables, while CreateMesh(), CreatePivot() and CreateSprite() return Memory pointer ( that are ... Global using your definition ? ). Cam is a global variable !

If we leave the function where they are created, Sprite,Mesh and Pivot are "0", but entitys created will remain.

i=12


Here "i" is a local variable, and if we leave the function where it was created, i is released, and "12" ... "12" is just a number, what happens to it when we leave the function ? :)

Dim Entitys(3)
Entitys(0)=Mesh
Entitys(1)=Piv
Entitys(2)=Sprite


Array can be accessed anywhere +> Here, it's the list of my variables ( LOCAL Variable ). Now, I can access any Entitys, anywhere in my code. So, as the list is global, Mesh,Sprite and Piv become global ???

types are just types !
you can point them with global or local variable, but the instance of the type you create is neither local or global.
We can use For/Each to access them later, as we can use an array to store locals entitys ^^.
t.MyType=New MyType

t is the variable, and t is local, and the instance created is global.
but if we leave the function, t can be used again, and can become a Int, or a Float or whatever. so "t" is a Local variable !

We can't say Memory pointers are global, they are just pointer, and nothing else.
Variables used to remember thoose pointers (Sprite,Mesh Pivot, and Cam AND "t") can be global or local.


If they can be accessed from anywhere in your code ( inside or outside functions ) then they are Global by definition.


As they are stored in memory and not released at end of functions, we can say they are globals, so any entitys in blitz3d are globals, and Images, Textures and Buffers too.

There is not only Globals and Locals . There is functions, pointers and else. Don't forget it, it 's just not the same thing.
"CreateCamera()" is not a variable, like "New MyType".
If you Include a source file to your project, then you can access it. So an included source file is global. That has no sense