Skip to content
Snippets Groups Projects
Commit 9a7ba18a authored by Patrick Dular's avatar Patrick Dular
Browse files

Update

parent 3727d808
Branches
Tags
No related merge requests found
......@@ -4,7 +4,7 @@
// A data structure is a group of data elements grouped together under one name,
// the structure identifier. These data elements, defining the structure members,
// can be of different types: real, string, list of real.
// can be of different types: real, string, list of real, list of string.
// The syntax should be clear from the example below:
Struct struct_identifier [
......@@ -26,8 +26,8 @@ Struct St1 [ Type 1 ]; // Tag will be 2 = 1 (the one of last Struct) + 1
Struct St2 [ Type 2, Tag 10 ]; // Tag is forced to 10
tag_of_struct_St3 = Struct St3 [ Type 3 ]; // Tag will be 11 = 10 + 1
// For clear classifications (contexts), structures can be defined in a
// given namespace (other than the global one used until now).
// For clear classifications (contexts), structures can be defined in
// namespaces (other than the global one used until now).
// Their names then start with the namespace name followed by the
// scope operator '::'. The 'Tag' numbering is proper to each namespace. E.g.,
......@@ -41,28 +41,29 @@ Struct NS1::St3 [ Type 3 ];
val_Type_of_Struct_St2 = St2.Type;
val_Type_of_Struct_St2_in_NS1 = NS1::St2.Type;
// Access to list members
// To access real list members:
one_element_from_a_list_member = struct_identifier.struct_member_list_of_real_1(1);
full_list_from_a_list_member() = struct_identifier.struct_member_list_of_real_1();
dim_list_member = #struct_identifier.struct_member_list_of_real_1();
// To access string list members:
one_string_from_a_list_member = Str[struct_identifier.struct_member_list_of_string_1(1)];
full_string_list_from_a_list_member() = Str[struct_identifier.struct_member_list_of_string_1()];
dim_string_list_member = #struct_identifier.struct_member_list_of_string_1();
// The function DimNameSpace(.) returns the number of structures in a given namespace:
// Function DimNameSpace(.) returns the number of structures in a given namespace:
nb_struct_namespace_global = DimNameSpace();
nb_struct_namespace_NS1 = DimNameSpace(NS1);
// The function NameStruct(namespace::#index)
// Function NameStruct(namespace::#index)
// (or NameStruct(#index) for the global namespace)
// returns the name (as a string) of the index-th structures in the given namespace:
name_of_struct_2_in_namespace_global = NameStruct(#2);
name_of_struct_2_in_namespace_NS1 = NameStruct[NS1::#2];
// Thanks to these two functions, and the S2N[.] function ('StringToName'),
// Thanks to these two functions, and function S2N[.] ('StringToName'),
// one can make loops on structures of a given namespace and
// access their members values:
......@@ -81,6 +82,7 @@ EndFor
Struct NS1::St2 (Append) [ AdditionalMember 222 ];
Struct NS1::St3 (Append) [ AdditionalMember 333, HColor "Orange" ];
// STRUCT FOR ENUMERATIONS
// A structure can be used to define an enumeration, to give automatically
// incremented values to the members (by default, starting at 0, or at any fixed value).
// This is useful, e.g., for defining constants to be used for types (hidding the values):
......@@ -91,7 +93,7 @@ Struct T::REGION_TYPE [ Enum, NONE, PHYS, SKIN, GATE, BC ];
Struct T::REGION_TYPE_2 [ Enum, PHYS 10, SKIN, GATE 20, BC ];
// Automatic values will be: PHYS 10, SKIN 11, GATE 20, BC 21
// Add members with Append:
// To add members with Append:
Struct T::REGION_TYPE (Append) [ Enum, CUTBOX ]; // CUTBOX will be 5
// Using explicit name for constants:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment