Noob Array and Const problem

BlitzMax Forums/BlitzMax Beginners Area/Noob Array and Const problem

H&K(Posted 2006) [#1]
Why is [0.0] not a const? (or [0.0,0.0,0.0])


Yan(Posted 2006) [#2]
Eh??


tonyg(Posted 2006) [#3]
I think I'm missing something but here goes...
'[' is an invalid variable character?
but I am guessing you actually typed something different in your code.


H&K(Posted 2006) [#4]
Const GF:Float[]	= [0.0,0.0,0.0]
or
Function Create:TV(PArray:Float[] = [0.0,0.0,0.0] )
For example

Or anytime I wanted to allocate a constant.

Sorry, maybe I was a bit "Unspecific" in the first post.
Why is it that if I try to allocate [0.0] (Or [0.0,0.0,0.0] for example) to a constant. The compiler tells me that [0.0] isnt a constant

So any ideas why [0.0] isnt a constant?


Dreamora(Posted 2006) [#5]
I'm not fully sure but I think the problem is not the [0.0] but the fact that an array can't be constant as it is dynamically allocated in runtime.


H&K(Posted 2006) [#6]
Any ideas then how to have a default array in the params. Because as far as Im aware if I dont give a default, then I do need to pass an arrary every time.

ie
bob:Type = Type.Create(anArray)
Fred:Type = Type.Create



Dreamora(Posted 2006) [#7]
the only default you can give is =null (as with types in general)


Yan(Posted 2006) [#8]
Test([1, 2, 3, 4, 5])
Print
Test()

End

Function Test(array[]=Null)
  If array = Null Then array = [10, 20, 30]
	
  For Local a = EachIn array
    Print a
  Next
End Function

??


H&K(Posted 2006) [#9]
I knew it would be something obvious that would make me look stupid
Thanks