Clearing my knowledge of BMax Arrays stinks

BlitzMax Forums/BlitzMax Beginners Area/Clearing my knowledge of BMax Arrays stinks

Grey Alien(Posted 2007) [#1]
should been "Clearly" ...

because how come if I use this within a Type declaration it fails to compile (actually it fails outside of type declaration too):

Const MultiplierArray%[]=[1,2]


yet this works

Field MultiplierArray%[]=[1,2]


?

This also fails:

Const MultiplierArray%[2]=[1,2]


So does this:

Const MultiplierArray%=[1,2]


and this:

Const MultiplierArray%[1,2]


so for now I'm just using a field that I've initialised. Where am I going dumbly wrong, thanks!


semar(Posted 2007) [#2]
Usually Const is used to give a constant value - and only one - which does not change during the program execution.

I don't think that an array can be declared as a constant value, due of its variable nature - that is, an array can change its values.

Hope this has sense for you,
Sergio.


Brucey(Posted 2007) [#3]
... I seem to have a case of the double-posts this month...


Brucey(Posted 2007) [#4]
Aye, it would be nice to be able to declare an array constant, for static stuff.

or

1) declare as a field/global and just don't change it ;-)

2) declare as a field/global, but use a method/function to access the values - which you expose in your API. eg.
Function getMultiplierArray%(index:int)
    Return getMultiplierArray[index]
End Function


etc


Grey Alien(Posted 2007) [#5]
Ah ok then so no Const arrays. Weird I'm very used to them from Delphi and other languages, oh well. Thanks.


bradford6(Posted 2007) [#6]
just make the variable name ALL_CAPS and don't change the value and poof! a Const. :)