-
-
July 30, 2024 at 2:40 pmfrederik.schmitzSubscriber
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 -
July 31, 2024 at 5:44 amAniketForum Moderator
sorry can you please elaborate which Ansys product you are using here?
-Aniket
-
July 31, 2024 at 7:55 amfrederik.schmitzSubscriber
Â
I’m using Scade Suite 2024 R1
Â
-
July 31, 2024 at 3:31 pmBenjamin DescorpsAnsys 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
Â
-
August 7, 2024 at 8:13 amfrederik.schmitzSubscriber
Hi Benjamin
Thanks yes that helped
Cheers -
November 26, 2024 at 1:45 pmsteven0smith01Bbp_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.
-
- The topic ‘array inside structure’ is closed to new replies.
-
1762
-
635
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.