Numeric array variable initialization
Hello there.
I'm stuck with a somehow simple problem. I can't create a variable type array and initialize it unless I enter a number. Take a look at this code:
let myArray := [];
for x from 1 to 10 do
let newNumber := [number(x)];
myArray := array(myArray, newNumber)
end;
concat(myArray)
It returns nothing. But add a 0 to the array definition, like this:
let myArray := [0];
for x from 1 to 10 do
let newNumber := [number(x)];
myArray := array(myArray, newNumber)
end;
concat(myArray)
And it returns a list of numbers:
0,1,2,3,4,5,6,7,8,9
So, how can I initialize a numeric array WITHOUT inserting any number in the array definition?
NOTE: For initializing an string array, there is already an easy method; you just type an empty string:
let myTextArray := [""];
9 replies
-
Ninox needs to know the exact type of variable to set it. You cannot create a variable with an unknown type as JavaScript.
About your code, you can simplify it, then you don't have to initialize with [0] :let myArray := for x from 0 to 10 do x; end; concat(myArray);
-
After Günther posted this solution I made a test database with some additional array manipulations. I can't test it against your code right now, but it might help.
Content aside
-
1
Likes
- 2 yrs agoLast active
- 9Replies
- 473Views
-
3
Following