From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ecc058d81d1613b5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.181.13.205 with SMTP id fa13mr8664213wid.3.1356652435804; Thu, 27 Dec 2012 15:53:55 -0800 (PST) Received: by 10.49.35.77 with SMTP id f13mr4885541qej.4.1356652435369; Thu, 27 Dec 2012 15:53:55 -0800 (PST) Path: i11ni296698wiw.0!nntp.google.com!m1no5866559wiv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 27 Dec 2012 15:53:55 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=77.11.81.165; posting-account=R80nsQoAAADNWKZhSnWyt-Rp7ZyxrQGD NNTP-Posting-Host: 77.11.81.165 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8b12ba84-4753-4b57-b026-ab2bfb148a4a@googlegroups.com> Subject: Re: Help on record to a Newbie From: Cedric Injection-Date: Thu, 27 Dec 2012 23:53:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-12-27T15:53:55-08:00 List-Id: 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 bod= y of the package. The things is: I have learnt Pascal sometime and liked it a lot. I have sti= ll a book about Pascal containing a set of units that helped me learn progr= amming in Pascal and write my own programs. I thought it would be a good tr= aining to use the little knowledge of Ada I have so far and implement the P= ascal 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 ha= ve 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=20 -- 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 :=3D 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 :=3D 0 --> Conversion OK -- t_err :=3D 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 :=3D black_n_white; t_config.background :=3D black; t_config.foreground :=3D white; -- Set the terminal background color -- Set the terminal foreground color -- to be done, but do not know how to do it =20 -- Clear the screen -- to be done, but do not know how to do it end t_decl; -- EOF Kind regards Cedric