Method or functions?

BlitzMax Forums/BlitzMax Beginners Area/Method or functions?

Rimmsy(Posted 2005) [#1]
Hi, i saw in another thread that someone was doing:
type test
   field id
   method update()
       id:+1
   end method
   function init()
      id=rand(1,100)
   end function
end type

if there any difference between using function instead of methods inside types?


Dreamora(Posted 2005) [#2]
methods are on type instance so they are called this way

entity:test = new test

entity.update


while functions are on type level. they are not connected to any type instance. so in your example the function is completely useless as it can not access any id. it would need to be "global id" to be a variable on type level as well

general use of functions are constructors with parameters


Rimmsy(Posted 2005) [#3]
ah, I see. Thanks for the info.