Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Dynamic Array Struct...

    Coding
    3
    6
    330
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Electric Dreams
      Electric Dreams F last edited by Martin

      Is it possible to create dynamic arrays for struct ?
      If I get the exemple about struct with no dimension I obtain a error...

      struct shape
          string name
          int sides
          int size
          vector pos
          int col
      endStruct
      
      shape shapes[]
      

      In the worst case, I could create an array with only one object and redim it (add or remove) with code but I can't find instruction to do it...

      Does anyone find a way ?

      1 Reply Last reply Reply Quote 1
      • N
        Nisse5 F last edited by Nisse5

        Try the syntax:

        shape shapes = []
        

        Here are more discussions on the subject:
        https://fuzearena.com/forum/topic/254/dynamic-array-sizes/7

        1 Reply Last reply Reply Quote 0
        • Electric Dreams
          Electric Dreams F last edited by

          Not the same error, but still not doing the job.
          Thanks for your link

          1 Reply Last reply Reply Quote 1
          • Electric Dreams
            Electric Dreams F last edited by Martin

            not perfect, but it works :

            struct shape
            string name
            int sides
            int size
            vector pos
            int col
            endStruct
            
            shapes=[]
            shapes[0] = [ .name = "triangle", .sides=3, .size=150, .pos = { 400, 150 }, .col = red ]
            shapes[1] = [ .name = "square",   .sides=4, .size=150, .pos = { 400, 500 }, .col = yellow ]
            
            1 Reply Last reply Reply Quote 1
            • Martin
              Martin Fuze Team last edited by

              @Electric-Dreams edited your text to make the code clearer.

              Please see this post in the FAQ (last question): https://fuzearena.com/forum/topic/226/faq-common-questions-and-answers/4

              1 Reply Last reply Reply Quote 0
              • Electric Dreams
                Electric Dreams F last edited by

                Very nice !
                Thank's you for the tips @Martin

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post