Embedded Software

Embedded Software

Topics related to SCADE Suite, SCADE Display, SCADE One and more.

array inside structure

    • frederik.schmitz
      Subscriber

      Hi

      if i wan't to create a structure that holds an array, i currently have to create the array structure as seperate types and then include the array as a Definition Element. With a lot of types and big structures, the folder Types becomes very hard to read.

      Is it possible to define an array insede the structure itself? And would it also be possible to have a structure with a structure inside? 

      It works as it is right now. But it would clean up the Types folder 

    • Aniket
      Forum Moderator

      sorry can you please elaborate which Ansys product you are using here?

      -Aniket

      Forum Rules & Guidelines

    • frederik.schmitz
      Subscriber

       

      I’m using Scade Suite 2024 R1

       

    • Benjamin Descorps
      Ansys Employee

      Hello,

      You have the possibility to use anonymous type (using the tetxual syntax of the Scade language). Here is an example of a structure that use as label both an array and a structure:

       

      Even if this is feasible and correct, I strongly recommend you to use Named as much as possible. Indeed, having named types improves readability and maintanability of the model. It also allows to reuse the type definitions while this is not posisble with anonymous type.

      In a Scade model, types definitions are often decomposed starting from basic types (i.e. temperature: float32) shareable between different projects to more complex types specific to the current project (T_struct: {currentTemp: temperature,  targetTemp: temperature, idle: bool}).

      Hope this helps,

      Benjamin

       

    • frederik.schmitz
      Subscriber

      Hi Benjamin

      Thanks yes that helped

      Cheers

    • steven0smith01
      Bbp_participant

      Certainly! Here's a concise and helpful reply:


      Yes, you can define an array directly inside a structure, depending on the language or tool you're using. Typically, you specify the array as a property within the structure itself. Similarly, nesting structures is also possible by defining one structure as a property of another.

      This approach keeps your code cleaner and more readable, reducing clutter in the Types folder. Here's a quick example:

      // Example with an array and nested structure
      struct Parent {
          int array[10];      // Define array directly
          struct Child {      // Nested structure
              int value;
          } child;            // Include nested structure
      };
      

      Check your language's documentation for syntax specifics, but this pattern should streamline your folder organization while maintaining functionality.

Viewing 5 reply threads
  • The topic ‘array inside structure’ is closed to new replies.