BUG in arrays
-
Arrays in fuze have a bug,
if you set Int, float , Struct in array everything is working fine, but string array have a bug ;Exemple with Integer:
array a[3] = [33,15,-54] loop clear() print(a[1]) update() repeat
Execute the program and on the display you can see 15, it's normal.
Now, with string :
array a[3] = ["Robert","Evan","Dave"] loop clear() print(a[1]) update() repeat
Now, on the display you can see : ["Robert","Evan","Dave"]
like that,direcly ! What ???? this should happen with the syntax: print(a)
Normaly you must see "Evan" It's a bug or It's me ? -
This does seem like a bug with the array initialization to me
With the size specified each element of the array seems to contain an array with all 3 elements.
The following behaves as expected
a = ["Robert","Evan","Dave"] loop clear() print(a[1]) update() repeat
I will report it. Thanks for your report
-
There is some misunderstanding here I think. I do not think there is a bug here.
The way you are declaring the array is a shorthand syntax to initialise an array of 3 elements each of which containing an array of 3 defined elements.
I am confused because your first example should not print a single number. It should print [33,15,-54], since that array of 3 elements is stored in each element of your array called 'a'
array a[3] = [15, 64, 2]
This is the same as doing this:
a = [ [15, 64, 2], [15, 64, 2], [15, 64, 2] ]
Same applies to the strings. If the first example does indeed only print a single number, then that would be a bug. However, I just tested this on our development build and the retail version and both are working as we'd expect. I'm not sure why you got a readout of just a single number..
-
Yes you are right, I should have done more testing Yes in the fuze help menu the declaration is like that :
array a[3] a[0] = 15 a[1] = 64 a[2] = 2
It is the reflex of c ++ ... In c++ you can set all your array in one line
-
@EvanTropFun You can declare this in one line in fuze too!
a = [15, 64, 2]
The Help tutorial for Arrays does show the first, long method first just for clarity. Below that is a shorthand declaration. Both of the below examples produce the same result:
Eg 1:
array answers[4] answers[0] = "It is certain!" answers[1] = "It does not look good..." answers[2] = "You might be in luck!" answers[3] = "Definitely not"
Eg 2:
answers = [ "It is certain!", "It does not look good...", "You might be in luck!", "Definitely not" ]
This one could be declared on one line too:
answers = ["It is certain!", "It does not look good...", "You might be in luck!", "Definitely not"]
-
@Dave Ok I will remember this syntax Thanks you !
-
@EvanTropFun Well I obviously didn't!