From: Cedric <Cedric.Lannock@gmx.net>
Subject: Re: Help on record to a Newbie
Date: Thu, 27 Dec 2012 15:53:55 -0800 (PST)
Date: 2012-12-27T15:53:55-08:00 [thread overview]
Message-ID: <8b12ba84-4753-4b57-b026-ab2bfb148a4a@googlegroups.com> (raw)
In-Reply-To: <e0c99332-4f90-4d84-bc54-43d0fb7f5754@googlegroups.com>
Am Donnerstag, 27. Dezember 2012 20:31:19 UTC+1 schrieb Cedric:
Hi All,
many thanks for all your help.
I think you got the point: I missed to define the specification and the body of the package.
The things is: I have learnt Pascal sometime and liked it a lot. I have still a book about Pascal containing a set of units that helped me learn programming in Pascal and write my own programs. I thought it would be a good training to use the little knowledge of Ada I have so far and implement the Pascal library in Ada. I think I will come across a lot of difficulties. If I solve them, I will be good in programming Ada in the end.
@Jeffrey:
What is so bad about my programming style? I thought it would be good to have a letter indicating the library I write.
Another question: How do you distinguish between types and variables. When reading my programs I find it a lot easier to see directly if it is a type or a variable. What does your programming style look like?
@Niklas:
Please find below the complete file:
-----------------------------------------------------------
-- file : t_decl.ads
--
-- date : 2012-12-20
-- update : 2012-12-27
--
-- compiler : GNAT GPL 2012 (20120509)
--
-- Author : Cedric
-----------------------------------------------------------
-- This file contains general definitions.
-- Types and constants are declared and variables defined.
-----------------------------------------------------------
package t_decl is
-- types --
subtype t_str2_type is string (2);
subtype t_str3_type is string (3);
subtype t_str4_type is string (4);
subtype t_str5_type is string (5);
subtype t_str6_type is string (6);
subtype t_str7_type is string (7);
subtype t_str8_type is string (8);
subtype t_str9_type is string (9);
subtype t_str10_type is string (10);
subtype t_str11_type is string (11);
subtype t_str20_type is string (20);
subtype t_str30_type is string (30);
subtype t_str40_type is string (40);
subtype t_str50_type is string (50);
subtype t_str60_type is string (60);
-- maximum length of line
subtype t_longstring_type is string (127);
-- work string of 79 characters
subtype t_workstring_type is string (79);
type t_yes_type is ('j', 'J');
type t_no_type is ('n', 'N');
-- Different alternatives of declaring that type
-- Alternative 1 is not a good choice
-- cause the type can get any character instead of
-- only "J" or "N"
-- type t_yes_or_no is array(1..1) of character;
-- Alternative 2 is not a good choice
-- cause the input of a character can not directly
-- be compared with that type
-- type t_yes_or_no is (j, J, n, N);
-- Alternative 3 is OK
-- type t_yes_or_no_type is character('j', 'J', 'n', 'N');
-- Alternative 4 is OK and chosen
type t_yes_or_no_type is ('j', 'J', 'n', 'N');
-- This type definition for an array is used to store 500
-- strings with a maximum length of 10 characters.
-- This array is handed over to a procedure which converts
-- the array into numbers of type float. These numbers will
-- then be processed.
type t_ary500_str10_type is array (integer range 1 .. 500) of t_str10_type;
-- The record definition and the type
-- t_selection_rec_type will be used within the function
-- t_selection_bar from the unit t_io.
-- It is assumed that the program will run on terminals
-- displaying 80 columns and 40 lines.
subtype t_lines_type is integer range 1 .. 40;
subtype t_columns_type is integer range 1 .. 80;
type t_selection_rec_type is
record
label : string (1 .. 30);
line : t_lines_type;
column : t_columns_type;
end record;
type t_bar_type is array (integer range 1 .. 40) of t_selection_rec_type;
-- For the drop down menu the 8 items of length 20 are
-- defined.
type t_ary_menu1_type is array (integer range 1 .. 8) of t_str30_type;
-- This type definition is used for the selection of the
-- terminal and for the setting of foreground and back-
-- ground colors. The following values can be used:
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;
-- constants --
t_esc : constant character := ASCII.ESC;
-- variables --
t_key : character; -- for key stroke, e. g. ctrl-key
t_ok : boolean; -- for general use
-- A type register has to be defined. This type shall be
-- used to access the processor registers of a standard
-- Intel processor.
-- to be done
-- Error information, e. g. for procedures that convert
-- something:
-- t_err := 0 --> Conversion OK
-- t_err := 1 --> Conversion not OK
-- The variable will be set to "0" in the unit t_check.
-- Conversion will be done anyway but with result "0".
-- Ann.: This way of Turbo Pascal programming has to be
-- changed to the Ada way of programming.
t_err : integer range 1 .. 1000;
-- Terminal type and colors
t_config : t_configure_type;
t_yes_no : t_yes_no_type;
t_yes : t_yes_type;
t_no : t_no_type;
t_config.terminal := black_n_white;
t_config.background := black;
t_config.foreground := white;
-- Set the terminal background color
-- Set the terminal foreground color
-- to be done, but do not know how to do it
-- Clear the screen
-- to be done, but do not know how to do it
end t_decl;
-- EOF
Kind regards
Cedric
next prev parent reply other threads:[~2012-12-27 23:53 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
2012-12-27 20:25 ` Shark8
2012-12-27 23:53 ` Cedric [this message]
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