Arrays containing floating points

BlitzMax Forums/BlitzMax Beginners Area/Arrays containing floating points

Emmett(Posted 2005) [#1]
Thank you all for the help on understanding slices. I spent last evening just experimenting with that. Got a good grasp of it now.

I cannot figure out how to create an auto array that contains floating point numbers. The end result needed:
sa[.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0]
A simple 10 element array containing decimal point numbers.


fredborg(Posted 2005) [#2]
a:float[] = [0.1,0.2,0.3] etc.
or
a#[] = [0.1,0.2,0.3] etc.


Emmett(Posted 2005) [#3]
I have tried both of those methods. Here is the code copied directly from the IDE.
sa:Float[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
sb#[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]

I comment out sb# and use only sa:Float[] it nets this compile error
Expecting expression but encountered '='

I comment out sa:Float and use only sb# it nets this compile error:
Expecting expression but encountered '='


Extron(Posted 2005) [#4]
Try Local or Global :

For local array :
Local sa:Float[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
Local sb#[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]

For global array :
Global sa:Float[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
Global sb#[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]


Emmett(Posted 2005) [#5]
Local sa:Float[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0] works fine.
added Local to sb#[] and got this compile error:
Expression of type 'Int' cannot be indexed

Global sa:Float[] = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0] works fine.
added Global to sb#[] and got this compile error:
Expression of type 'Int' cannot be indexed


teamonkey(Posted 2005) [#6]
What's the whole of the line that's causing the error?


Emmett(Posted 2005) [#7]
Oops, that's the answer teamonkey.
Local and Global works for sa[] and sb[] but when using sb[] I forgot to change the line that uses the elements.

Thanks all, I think this assigning arrays is understood. Just have to remember to add Local or Global and make sure the variable names match throughout the code.