Globals inside Functions
Blitz3D Forums/Blitz3D Beginners Area/Globals inside Functions
| ||
Is there anyway to get around this? It won't let me create a global inside a function. |
| ||
Correct... Create them outside a function. This is normal programming behaviour as far as I'm aware as if your function was called recursivly it would be very messy indeed. |
| ||
You should just declare all your globals at the start of the program. Why would you be declaring them in a function any way? |
| ||
Well i am loading my models in and globalising the name so i can use them in creation functions, and i just wanted to put them in a function in an include to keep them neat. i will just not put them inside a function in an include then :) |
| ||
Why not just declare the model variables as globals global MyShip global EnemyShip and then do what your doing ... Function LoadStuff() Myship = loadmesh("Blah") end function etc... |
| ||
Thats what I always do! |
| ||
sometimes the code would be much better structured if you could declare globals inside functions. It would not get messed up if you call the function twice. But you should never do that. this works fine For a=1 To 2 Local x Print x x=1 Next |