



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Prof. Balamohan Pawar delivered this lecture at Allahabad University for Aeronautical Engineering and Computer Programming course. Its main points are: Concept, Record, Cored, Compilation, Field, Type, End, Outer, Declare, Element, Single
Typology: Slides
1 / 5
This page cannot be seen from the preview
Don't miss anything!




(38 respondents)
type My_Record_1 is record Name : String (1..10); Age : Integer; Location : String ( 1..10); end record ;
After those declarations we assigned 2 records and give them their values:
My_First_Record : My_Record_1 := ("John Doe ", 25,"Detroit Mi"); My_Second_Record : My_Record_2 := ("Jane Doe ", 30,"New York ");
Which meens that "My_First_Record" is a record of type 'My_Record_1' and at the same time gets assigned values for each field.
Within the main section of the procedure we then perform operations on these two reocrds, My_First_Record and My_Second_Record.
2 ) In your code, you often use Put("Blah"), but when I've tried this command, I get a compilation error. I have to use Ada.Text_Io.Put("Blah"); Why? (1 student) That is correct. You will always have to use the correct IO routines for the kind of types you want to read/print. I very often exclude the lines e.g, "With Ada.Text_IO; use Ada.Text_IO;" in my examples to save space and time.
3 ) How can we make fields within fields? (1 student) Take a look at the Ada file "complex_persons.adb" that was distributed in class. It defines a record with in a record. That is, the field "Name" is in it self a record with 3 fields for "Title, First name, and Surname".
--variable declarations
type Inner_Record is record
Field_1 : Integer;
Field_2 : Character;
end record;
type Outer_Record is record
Field_A : Integer;
Inner_Record_Name : Inner_Record;
end record;
Outer_Record_Name : Outer_Record;
-- main program
Outer_Record_Name.Inner_Record_Name.Field_In_Inner_Record
The ‘.’ Operator allows the programmer to access fields of the record. The same operator used in succession can be used to access fields of inner records.
4 ) What is the point of using arrays, how are they different from records? and similar questions ( students)
Arrays are used to store homogenous data (data of the same type). A record on the other hand, can have data of different types as its fields. You can, for instance, have:
-- sorting procedure
for I in 1 .. Num_Of_Aircraft - 1 loop
for J in I+1 .. Num_Of_Aircraft loop
if Input_Array(I).Latitude > Input_Array(J).Latitude then
Temp:= Input_Array(I);
Input_Array(I) := Input_Array(J);
Input_Array(J) := Temp;
end if;
end loop;
end loop;
7 ) Why are two records with the same data of different types? (1 student) As far as the compiler is concerned, they are defined as different types and can have different operations associated with them.
8 ) What does "(others => space);" do? (1 students) The others=> space operations is called the ‘aggregation’ operation. It fills the remaining fields with blank spaces.
9 ) Is there a way to display the entire record by a single command? (1 student) You can write a procedure to display each of the fields and call the procedure. Other than that, there is no predefined Ada library function that will allow you to display all the elements in a record.
10 ) Is there a way to make actual tables in Ada? Without teadious hand formating, like with borders and stuff? (1 students)
11 ) What is the purpose of Nchar in the second code example? (1 student) Nchar keeps track of how many characters have been entered as input. That information is never used in the code, so it should have been removed.
12 ) How can I get an input from the user and stay on the same line? that is, I want to print something on the same line as something I get? (1 student) Move the Skip_Line command to the line after you display your outputs. This will allow you to display
output on the same line.
13 ) Give me pointers, we are so close now! (1 student) Yes we are... and pointer will be covered in beginning of spring term.
14 ) Handling files, making columns and screen formating? and similar questions (4 students) Will be covered more next term.
15 ) "No mud" (15 students) Good :-)