ÏÏ«Ï ----jGRASP exec: gcc
-c -gnatc date.ads semantic check
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. date.ali created
ÏÏÏÏ
ÏÏ«Ï
----jGRASP exec: gcc -c -g date.ads compile file
ÏϧÏ
ÏϧÏcannot generate code
for file date.ads (package spec)
ÏϧÏto check package spec for errors, use -gnatc
ÏϧÏ
ÏϧÏ
----jGRASP wedge2: exit code for process is 1.
ÏÏ©Ï ----jGRASP: operation complete.
Ï«Ï ----jGRASP exec: gnatmake -g date.ads compile & link file
ÏϧÏ
ÏϧÏgcc -c -g date.ads
ÏϧÏcannot generate code for file date.ads
(package spec)
ÏϧÏto check package spec for errors, use -gnatc
ÏϧÏgnatmake: "date.ads"
compilation error
ÏϧÏ
ÏϧÏ
----jGRASP wedge2: exit code for process is 4.
ÏÏ©Ï ----jGRASP: operation complete.
ÏÏÏ
ÏÏ«Ï
----jGRASP exec: gcc -c -gnatc date.adb semantic check
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. date.ali created
ÏÏÏÏ
ÏÏ«Ï
----jGRASP exec: gcc -c -g date.adb compile
file
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. date.o created
ÏÏÏÏ
ÏÏ«Ï
----jGRASP exec: gnatmake
-g date.adb compile
& link file
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete.
Ï«Ï ----jGRASP exec: gcc -c -gnatc use_date.adb semantic check
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. use_date.ali created
Ï «Ï ----jGRASP exec: gcc
-c -g use_date.adb compile file
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. use_date.o created
Ï«Ï ----jGRASP exec: gnatmake -g use_date.adb compile & link
file
ÏϧÏ
ÏϧÏgcc -c -g date.adb
ÏϧÏgnatbind -x use_date.ali
ÏϧÏgnatlink use_date.ali -g
ÏϧÏ
ÏÏ©Ï
----jGRASP: operation complete. creates: date.ali date.o b~use_date.ali
b~use_date.o b~use_date.adb b~use_date.ads AND use_date.exe
created
ÏÏÏ
ÏÏ«Ï ----jGRASP exec:
U:\Web\CS240_Fall_2007\Chapter 01- Text book code\use_date
ÏϧÏ
ÏϧÏ
ÏÏ©Ï ----jGRASP: operation complete.
¼¼ÏÏWhat’s
wrong???
1 ÏÏÏwith Date;
2 --use Date; -- FRIENDS DON'T LET FRIENDS USE USE CLAUSES!!!!
3 ÏÏÏwith ada.text_io;
4 ÏÏÏwith ada.integer_text_io;
5 ÏÞßàprocedure Use_Date_with_output is
6 ÏÏ§ÏØÓìpackage month_io is new ada.text_io.enumeration_io (date.month_type);
7 ÏÏ§ÏØÓìpackage year_io is new ada.text_io.Integer_io (date.year_type);
8 ÏÏ§ÏØÓìpackage day_io is new ada.text_io.integer_io (date.day_type);
9 ÏϧÏíÏMy_Date : date.Date_Type := date.Construct_Date
(date.December, 20, 1948);
10 ÏϧÏíÏYour_Date : date.Date_Type := date.Construct_Date (date.September,
30, 1948);
11 ÏϧÏíÏOur_Date : date.Date_Type := date.Construct_Date
(date.June, 17, 1971);
12 Ïϧ
13 ÏϧÏíÏThe_Year : date.Year_Type;
14 ÏϧÏíÏThe_Month : date.Month_Type;
15 ÏϧÏíÏThe_Day : date.Day_Type;
16 Ïϧbegin
17 ÏϨ¹¹Ïada.text_io.put (" The first data constructed is: ");
18 ÏϨ¹¹ÏThe_Month := date.Month_is(My_Date);
19 ÏϨ¹¹Ïmonth_io.put (The_Month);
20 ÏϨ¹¹Ïada.text_io.put (" ");
21 ÏϨ¹¹ÏThe_Day := date.Day_is(My_Date);
22 ÏϨ¹¹Ïday_io.put (The_Day);
23 ÏϨ¹¹Ïada.text_io.put (",");
24 ÏϨ¹¹ÏThe_Year := date.Year_Is (My_Date); -- old way of
doing it!
25 ÏϨ¹¹Ïyear_io.put (item =>The_Year, width
=>5);
26 ÏϨ¹¹ÏThe_Year := My_Date.Year_Is; -- object
oriented way of doing it!
27 ÏÏ©end Use_Date_with_output;
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
1 ÏÏÏwith date;
2 ÏÏÏwith ada.text_io;
3 ÏÞßàprocedure play_with_enumerated_types
is
4 ÏÏ§ÏØÓìpackage month_io is new ada.text_io.enumeration_io (date.month_type);
5 ÏϧÏíÏmyMonth : date.Month_type;
6 Ïϧ
7 Ïϧbegin
8 ÏϨ¹¹Ïada.text_io.put
9 ÏϧÏÏÏÏÏÏ(" please
enter your choice of month from the following list ");
10 ÏϨ¹¹Ïada.text_io.new_line;
11 ÏϨ¹¹±for i in date.Month_type'first
.. date.Month_type'last loop
12 ÏϧÏÏ7¹¹Ïmonth_io.put (i);
13 ÏϧÏÏ7¹¹Ïada.text_io.put (" ");
14 ÏϧÏϰend loop;
15 ÏϨ¹¹Ïada.text_io.new_line;
16 ÏϨ¹¹Ïmonth_io.get (myMonth);
17 ÏϨ¹¹Ïada.text_io.put
18 ÏϧÏÏÏÏÏÏ(" the month you entered is: ");
19 ÏϨ¹¹Ïmonth_io.put (myMonth);
20 ÏÏ©end play_with_enumerated_types;