Im trying to initialise a record variable that itself contains a nested record using an aggregate but can't seem to get the syntax right. Any help appreciated.
with Step; use Step;
package Pattern is
-- ADT
type Pattern_Type is tagged private;
-- ADT components
type Bars_Type is private;
-- ADT instance methods
function Tempo (This: Pattern_Type) return Integer;
function Bars (This: Pattern_Type) return Bars_Type;
function Get_Next_Step(This: Pattern_Type ) return Step_Type;
-- Static methods
function Get_Basic_Beat return Pattern_Type;
private
type Bars_Type is range 0..2;
Number_Of_Steps : constant Natural := 32;
type Active_Step_Type is mod Number_Of_Steps;
type Steps_Type is array( Active_Step_Type ) of Step_Type;
type Pattern_Type is tagged record
Tempo : Integer range 40..400;
Bars : Bars_Type := 1;
Steps : Steps_Type;
Active_Step : Active_Step_Type := 1;
end record;
-- Package variable
Basic_Beat : Pattern_Type :=
( Tempo => 125,
Steps => Steps_Type'(1..31 => Step_Type'(Instrument => 'K', Velocity => 127, Offset => 0, Active => True)),
others => <> );
end Pattern;
...and within steps.ads
package Step is
-- ADT
type Step_Type is tagged private;
-- ADT instance methods
function Instrument (This : Step_Type) return Character;
function Velocity (This : Step_Type) return Integer;
function Offset (This : Step_Type) return Integer;
function Active (This : Step_type) return Boolean;
private
type Step_Type is tagged record
Instrument : Character := ' ';
Velocity : Integer := 0;
Offset : Integer := 0;
Active : Boolean := false;
end record;
end Step;
I get this build error in GPS
expected private type "Step_Type" defined at step.ads:4, found a composite type
Ive tried various combinations of the Step_Type'... line
答案 0 :(得分:5)
您可以根据自己的需要选择不同的选项:
第2个示例:
'Table2'