* Re: An array of records within an array of records (Still a problem)
[not found] <354AEE03.424DC998@none.com>
@ 1998-05-02 0:00 ` David C. Hoos, Sr.
1998-05-02 0:00 ` Robert Dewar
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: David C. Hoos, Sr. @ 1998-05-02 0:00 UTC (permalink / raw)
Note: This same message was inadvertently sent earlier in Rich Text Format
(HTML). Sorry about that. Let's see if this is more readable.
Hi,
The error message means exactly what it says: you need a subtype mark where
you had put the name of an object.
The following code shows how it's done.
Also, note that you must assign all three elements of the track array,
otherwise you will get an error at run time,
Further, the use of named association instead of positional association, and
the organized layout of the assignment statement will make the code easier
to understand and maintain.
Finally, since many news readers cannot display HTML, you should use plain
text when posting to widely-read newsgroups.
with Ada.Text_Io;
procedure Mullen is
type Cd_Track is
record
Title:String(1..20);
Artist:String(1..20);
Playlength:Float:=0.00;
Id:Integer;
end record;
type Cd_Track_Array is array(1..3) of Cd_Track;
-- New_Cd_Track:Cd_Track_Array;
type Cd is
record
Title:String(1..20);
Artist:String(1..20);
Id:Cd_Track_Array;
Tracks:Integer;
end record;
type Cd_Array is array(1..3) of Cd;
New_Cd_Array:Cd_Array;
begin
New_Cd_Array (1) :=
(Title => "aaaaaaaaaaaaaaaaaaaa",
Artist => "bbbbbbbbbbbbbbbbbbbb",
Id => ( 1=> (Title => "cccccccccccccccccccc",
Artist => "dddddddddddddddddddd",
Playlength => 0.34,
Id => 1),
2=> (Title => "eeeeeeeeeeeeeeeeeeee",
Artist => "ffffffffffffffffffff",
Playlength => 0.35,
Id => 2),
3=> (Title => "gggggggggggggggggggg",
Artist => "hhhhhhhhhhhhhhhhhhhh",
Playlength => 0.36,
Id => 3)
),
Tracks => 3);
Ada.Text_Io.Put (New_Cd_Array(1).Id(1).Title);
end Mullen;
R Mullen wrote in message <354AEE03.424DC998@none.com>...
I wonder if anyone could help me out, my problem is that I am trying to
create an array of records within an array of records representing CD tracks
within a CD, however I have tried every possible solution but the error I
receive most is "Sub-type mark required in this context", this is on the
line where I am specifying the ID of the CD to the array of tracks.
my code is as follows:
type cd_track is
record
title:string(1..20);
artist:string(1..20);
playlength:float:=0.00;
id:integer;
end record;
type cd_track_array is array(1..3) of cd_track;
new_cd_track:cd_track_array;
type cd is
record
title:string(1..20);
artist:string(1..20);
id:new_cd_track;
tracks:integer;
end record;
type cd_array is array(1..3) of cd;
new_cd_array:cd_array;
begin
new_cd_array(1):=("qqqqqqqqqqqqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",("qqqqqqqqqq
qqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",0.34,1),3);
put(new_cd_array(1).id(1).title);
I am specifying the ID of the CD to the array of CD Tracks. I would of
thought it would work but as of yet it still wont. Although I have asked
this before the responses weren't really concerning the actual problem.
This is part of a larger coursework assignment this being a small
section, the course lecturer has had a look and cant figure it out yet,
could anyone have a look and tell me how I can incorporate an array of
records within an array of records and possibly fix this most annoying
error.
Any help greatly appreciated.
Thanks
(Using latest version of GNAT with TEXT_IO, with windows 95)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: An array of records within an array of records (Still a problem)
[not found] <354AEE03.424DC998@none.com>
1998-05-02 0:00 ` An array of records within an array of records (Still a problem) David C. Hoos, Sr.
@ 1998-05-02 0:00 ` Robert Dewar
1998-05-02 0:00 ` David C. Hoos, Sr.
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Robert Dewar @ 1998-05-02 0:00 UTC (permalink / raw)
R Mullen notes:
<< I am specifying the ID of the CD to the array of CD Tracks. I would of
thought it would work but as of yet it still wont. Although I have asked
this before the responses weren't really concerning the actual problem.
>>
How do you expect people to respond to "the actual problem" if you keep
secret what your problem is "it still won't (work)" is not exactly
a detailed problem report!
Actually the writer here is a student, who perhaps can be forgiven for
the vague report :-)
But I am constantly amazed by the reports we sometimes get from experienced
software engineers that are equally vague, and have phrases like
"doesn't work", "bombs" etc.
A good working rule whenever you ask anyone for help, either informally in
a context like this one, or when reporting a problem under a formal support
contract is:
(a) provide the entire code that shows the problem if you can, or
preferably (if you can) a cut down example.
(b) say exactly what you saw, in its entirety
(c) say why you think this report is wrong, and what you expected to see.
Part (c) is very important. It is a common occurrence for people to
post code that behaves exactly as one would expect given a reasonable
knowledge of Ada, and the issue is understanding the (often very strange)
misconception(s) that lead to the question being asked in the first place.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: An array of records within an array of records (Still a problem)
[not found] <354AEE03.424DC998@none.com>
1998-05-02 0:00 ` An array of records within an array of records (Still a problem) David C. Hoos, Sr.
1998-05-02 0:00 ` Robert Dewar
@ 1998-05-02 0:00 ` David C. Hoos, Sr.
1998-05-02 0:00 ` Arthur Ward
1998-05-04 0:00 ` Pascal Obry
4 siblings, 0 replies; 11+ messages in thread
From: David C. Hoos, Sr. @ 1998-05-02 0:00 UTC (permalink / raw)
Hi,
The error message means exactly what it says: you need a subtype mark where
you had put the name of an object.
The following code shows how it's done.
Also, note that you must assign all three elements of the track array,
otherwise you will get an error at run time,
Further, the use of named association instead of positional association, and
the organized layout of the assignment statement will make the code easier
to understand and maintain.
Finally, since many news readers cannot display HTML, you should use plain
text when posting to widely-read newsgroups.
with Ada.Text_Io;procedure Mullen is type Cd_Track is record
Title:String(1..20); Artist:String(1..20);
Playlength:Float:=0.00; Id:Integer; end record; type
Cd_Track_Array is array(1..3) of Cd_Track; -- New_Cd_Track:Cd_Track_Array;
type Cd is record Title:String(1..20);
Artist:String(1..20); Id:Cd_Track_Array; Tracks:Integer;
end record; type Cd_Array is array(1..3) of Cd;
New_Cd_Array:Cd_Array;begin New_Cd_Array (1) := (Title =>
"aaaaaaaaaaaaaaaaaaaa", Artist => "bbbbbbbbbbbbbbbbbbbb", Id
=> (1 => (Title => "cccccccccccccccccccc", Artist
=> "dddddddddddddddddddd", Playlength => 0.34,
Id => 1), 2 => (Title =>
"eeeeeeeeeeeeeeeeeeee", Artist =>
"ffffffffffffffffffff", Playlength => 0.35,
Id => 2), 3 => (Title =>
"gggggggggggggggggggg", Artist =>
"hhhhhhhhhhhhhhhhhhhh", Playlength => 0.36,
Id => 3) ), Tracks => 3); Ada.Text_Io.Put
(New_Cd_Array(1).Id(1).Title);end Mullen;
R Mullen wrote in message <354AEE03.424DC998@none.com>...
I wonder if anyone could help me out, my problem is that I am trying to
create an array of records within an array of records representing CD tracks
within a CD, however I have tried every possible solution but the error I
receive most is "Sub-type mark required in this context", this is on the
line where I am specifying the ID of the CD to the array of tracks.
my code is as follows:
type cd_track is
record
title:string(1..20);
artist:string(1..20);
playlength:float:=0.00;
id:integer;
end record;
type cd_track_array is array(1..3) of cd_track;
new_cd_track:cd_track_array;
type cd is
record
title:string(1..20);
artist:string(1..20);
id:new_cd_track;
tracks:integer;
end record;
type cd_array is array(1..3) of cd;
new_cd_array:cd_array;
begin
new_cd_array(1):=("qqqqqqqqqqqqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",("qqqqqqqqqq
qqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",0.34,1),3);
put(new_cd_array(1).id(1).title);
I am specifying the ID of the CD to the array of CD Tracks. I would of
thought it would work but as of yet it still wont. Although I have asked
this before the responses weren't really concerning the actual problem.
This is part of a larger coursework assignment this being a small
section, the course lecturer has had a look and cant figure it out yet,
could anyone have a look and tell me how I can incorporate an array of
records within an array of records and possibly fix this most annoying
error.
Any help greatly appreciated.
Thanks
(Using latest version of GNAT with TEXT_IO, with windows 95)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: An array of records within an array of records (Still a problem)
[not found] <354AEE03.424DC998@none.com>
` (2 preceding siblings ...)
1998-05-02 0:00 ` David C. Hoos, Sr.
@ 1998-05-02 0:00 ` Arthur Ward
1998-05-04 0:00 ` Pascal Obry
4 siblings, 0 replies; 11+ messages in thread
From: Arthur Ward @ 1998-05-02 0:00 UTC (permalink / raw)
On Sat, 02 May 1998 10:57:24 +0100, R Mullen <none@none.com> wrote:
>> type cd_track_array is array(1..3) of cd_track;
>> new_cd_track:cd_track_array;
>>
>> type cd is
>> record
>> title:string(1..20);
>> artist:string(1..20);
>> id:new_cd_track;
>> tracks:integer;
>> end record;
>>
>> type cd_array is array(1..3) of cd;
>> new_cd_array:cd_array;
>>
>> begin
>> new_cd_array(1):=("qqqqqqqqqqqqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",("qqqqqqqqqqqqqqqqqqqq","qqqqqqqqqqqqqqqqqqqq",0.34,1),3);
>> put(new_cd_array(1).id(1).title);
>>
> I am specifying the ID of the CD to the array of CD Tracks. I would of
>thought it would work but as of yet it still wont. Although I have asked
>this before the responses weren't really concerning the actual problem.
Your assignment of one CD only contains data for one cd_track; the cd
record contains a new_cd_track (how, I'm not sure; I would expect
you'd have to use a type in the declaration, not a variable, but hey,
whatever works), and a new_cd_track is an array of 3 cd_tracks. So,
your assignment needs to be a bit uglier, along the lines of:
new_cd_array(1):=(title,artist,((cd_track1),(cd_track2),(cd_track3)),tracks);
Note the array aggregate containing the cd_track aggregates.
- Arthur
(arthurw at bigfoot.com)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: An array of records within an array of records (Still a problem)
[not found] <354AEE03.424DC998@none.com>
` (3 preceding siblings ...)
1998-05-02 0:00 ` Arthur Ward
@ 1998-05-04 0:00 ` Pascal Obry
4 siblings, 0 replies; 11+ messages in thread
From: Pascal Obry @ 1998-05-04 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
Your playlength should not be of type float.
Try a fixed type with range constraint.
Pascal.
--
--|------------------------------------------------------------
--| Pascal Obry Team-Ada Member |
--| |
--| EDF-DER-IPN-SID- Ing�nierie des Syst�mes d'Informations |
--| |
--| Bureau G1-010 e-mail: pascal.obry@der.edfgdf.fr |
--| 1 Av G�n�ral de Gaulle voice : +33-1-47.65.50.91 |
--| 92141 Clamart CEDEX fax : +33-1-47.65.50.07 |
--| FRANCE |
--|------------------------------------------------------------
--|
--| http://ourworld.compuserve.com/homepages/pascal_obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 11+ messages in thread