comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Help on record to a Newbie
Date: Thu, 27 Dec 2012 21:51:54 +0200
Date: 2012-12-27T21:51:54+02:00	[thread overview]
Message-ID: <ak3n6sFerrsU1@mid.individual.net> (raw)
In-Reply-To: <e0c99332-4f90-4d84-bc54-43d0fb7f5754@googlegroups.com>

On 12-12-27 21:31 , Cedric wrote:
> Hi All,
> 
> I started learning Ada (it's the third time I try!).

Wishing you well in this...

It would be easier to help you if you showed the whole compilation unit
that is giving you trouble, and not just an extract of it.

> I defined and declared the following:
> 
>   type t_terminal_type is (black_n_white, black_n_yellow,
>                            black_n_green, color);
>   type t_color_type is (red, green, blue, yellow, black, white, grey);
>   type t_configure_type is
>     record
>       terminal   : t_terminal_type;
>       foreground,
>       background : t_color_type;
>     end record;
> 
>  t_config : t_configure_type;

That all looks like good declarations of some types and one object (a
variable).

But the following lines are *statements*, not declarations. You cannot
mix declarations and statements, you must separate them syntactically.
In most cases, the separator is the "begin" keyword.

>   t_config.terminal   := black_n_white;
>   t_config.background := black;
>   t_config.foreground := white;
> 
> The compiler (GNAT 2012) comes back with "declaration expected" for the last three lines.

That is expected: if the compiler accepted the declarations quoted
earlier, it expects more declarations, or some syntax that indicates the
end of the declaration list, such as "begin".

> As far as I understood the language I have declared the variable "t_config".

Yes.

> This variable has the components terminal, background and
> foreground of their respective types which can be accessed
> using dot-notation.

Yes.

> What did I miss here?

Perhaps a "begin" between the declarations and the statements?

I'm not sure exactly how to correct your code, since you didn't say if
the declarations are in a package declaration (.ads file -- you cannot
put any executable statements there), in a body (.adb file), or within a
subprogram in a body. If you show the whole file that contains the
things you quoted, you will get more precise help.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  parent reply	other threads:[~2012-12-27 19:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-27 19:31 Help on record to a Newbie Cedric
2012-12-27 19:50 ` Jeffrey Carter
2012-12-27 19:51 ` Niklas Holsti [this message]
2012-12-27 20:25 ` Shark8
2012-12-27 23:53 ` Cedric
2012-12-28  8:00   ` Niklas Holsti
2012-12-28  8:30     ` Cedric
2012-12-28  9:29       ` Simon Wright
2012-12-30 17:29       ` Niklas Holsti
2012-12-28 11:52 ` Cedric
2012-12-28 15:36   ` Shark8
2012-12-30 16:03   ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox