-
Array Question
I'm trying to figure out how to add a value to an array in the next available slot (without having to specify the slot number).
I've found where you can add to the current position, or to a specific slot, but I can seem to find the "add to next available slot" button :)
The closest work around I have found is to add the value to "the current position + 1".. This works perfectly, however it leaves the fist slot of the array blank (as its being skipped from the +1)...
Help a noob?
-
Not a hundred percent sure what you mean by "available slot." All array indexes are available at any time.
Are you saying you want to find the first array index that is equal to 0? In this case you'll need to use a fastloop:
This is pseudocode so there may be typos:
Code:
Always
--> Start loop "FindZero" XDimension("Array") times
On loop "FindZero"
+ ValueAtX("Array", loopindex("FindZero") ) is equal to 0
--> Array: Set value at X loopindex("FindZero") to [whatever you want]
--> Stop loop "FindZero"
Edit: forgot to mention this assumes you are using zero-based indexing with your array, which makes the most sense for almost all programming anyway.
-
I apologize for not being more clear in my goal -
Lets say we have an edit box that a user can input a string - upon pressing the "enter" key, I would like that string to be appended to the array in the first empty index.
I'm new to Fusion, so please excuse the noob question here..
I read online that its best to start your arrays with only one index for each dimension, and add as you need them (as you cant make the array smaller, you can only make it larger).. Is this true?
With that said, I've created a 1x1x1 array that I would like to append all of my strings to.
I've tried your code (of course, altered for strings and not values, etc).. It doesn't seem to resolve the issue.
I'm just trying to build onto the array..
If there is nothing in index zero, add it.. If there is something in index zero, create a new index and add it there.
I hope this makes better sense.
PS - I went to your website and downloaded several of your games. Trike and Chroma Cave are awesome man! Congrats!
-
mfa.aquadasoft.com/upload/1397400403-EX.mfa
-
klikhappy - this was incredibly helpful - basing the index off of the global value worked out perfectly!!! I cannot thank you enough!