Variables vs arrays ?



  • I’m trying to fully understand using one versus the other. Before I was just trying to get my program not to error and have it work but I see so many variations in how arrays versus (variables?) should be listed.

    string person=[] //use ‘string‘ or not?
    person[0]=“Tim”
    person[1]=“Dave”
    person[2]=“Joe”

    Or

    person=[1] //use ‘string‘ or not?
    person[0]=“Tim”
    person[1]=“Dave”
    person[2]=“Joe”

    Or

    string person=[3] //use ‘string‘ or not?
    person[0]=“Tim”
    person[1]=“Dave”
    person[2]=“Joe”

    Or

    array person [1]
    person[0]=“Tim”
    person[1]=“Dave”
    person[2]=“Joe”

    Or

    array person [3] //this looks right to me
    person[0]=“Tim”
    person[1]=“Dave”
    person[2]=“Joe”

    Can someone explain this to me?


  • F

    As far as I know they’ll all work, because the arrays grow automatically if you add more things, and also because fuze automatically handles types (string, int, vector, float).

    It’s a bit confusing to me too, I change up the way I do it depending on if I want to remind myself what type of data I’m keeping in them, or if I know I’m going to be adding things only one at a time, or if I’m trying to save memory. It just depends.

    That first one is new to me though...



  • @toxibunny thanks.

    I just went to the main Fuze site and saw there were 2 coding books to download and saw this in the second one on arrays

    ![alt text](1CB357EE-9D02-4CED-880A-9894496DE692.png image url)

    Information like this should be in the Fuze Help. I didn’t even know about the 2 coding downloads.

    Currently the Fuze help on Array only lists this:

    array myArray[elements]

    The download was much more helpful.


  • F

    I noticed this in your code and was wondering why you were doing that.
    A lot of your assigning of values looked exactly the same. the only thing that changed was the number of the array slot. A loop would be a better way.
    Also with arrays
    How_many_person = len( person )
    For I = 0 to how_many_person loop ...... repeat
    That way your always got the correct length of the array



  • @xevdev I printed out both coding projects books. I just finished reading both and these should be must reads!

    There is so much more info than what’s in the Fuse Help especially on Arrays, structures and functions.

    I’m planning on cleaning up my current FTA program in the arrays and better use of functions and structures.

    Tim

    link text


  • F

    @tdg8934 I didn’t even know these books existed, thank you!


Log in to reply