static?

BlitzMax Forums/BlitzMax Programming/static?

Craig H. Nisbet(Posted 2008) [#1]
I'm learning Blitz Max and C++ kind of at the same time. I was wondering if there is a equivalent statement for static in c++ to Blitz Max. This is the static that can be used in classes in C++.


slenkar(Posted 2008) [#2]
i read somewhere that putting a global in a type is a static variable


Azathoth(Posted 2008) [#3]
Yea, use Global.


Craig H. Nisbet(Posted 2008) [#4]
sweet!


Zethrax(Posted 2008) [#5]
You can also use Global as a static variable in a function.

Function IncAndPrint()
Global static_var = 10
static_var :+ 1
Print static_var
End Function

IncAndPrint()
IncAndPrint()
IncAndPrint()

End



Dreamora(Posted 2008) [#6]
if you use global in a Function / Method there are actually 2 different possibilities:

Static or Const

If you have global varname = XXX in a line it will end up as const at least on object. The new will not be reexecuted.
If you want the newe to be reexecuted, use global var and the initialization in a different line