PASCAL-80 Compiler V2.1 SEEKEX.PAS Page: 1 ISIS-II PASCAL-80 Compiler V2.1 invoked by: >:F0:comp.COD seekex.pas Line Seg Proc Lev Disp 1 1 1 1 program demo_seek; 2 1 1 3 3 1 1 3 type 4 1 1 3 status = (married, widowed, divorced, single); 5 1 1 3 date = record 6 1 1 3 month: (jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec); 7 1 1 3 day: 1..31; 8 1 1 3 year: integer; 9 1 1 3 end; 10 1 1 3 person = record 11 1 1 3 allocated: boolean; 12 1 1 3 name: record 13 1 1 3 first, last: string[20]; 14 1 1 3 end; 15 1 1 3 ssnum: integer; 16 1 1 3 sex: (male, female); 17 1 1 3 birth: date; 18 1 1 3 dependents: integer; 19 1 1 3 debts: integer; 20 1 1 3 case marital_status : status of 21 1 1 3 married, widowed: (date_married: date); 22 1 1 3 divorced: (date_divorced: date; first_divorce: boolean); 23 1 1 3 single: (independent: boolean); 24 1 1 3 end { person }; 25 1 1 3 26 1 1 3 var people: file of person; 27 1 1 58 ch: char; 28 1 1 59 recnumber: integer; 29 1 1 60 30 1 2 1 procedure initfile (only_one: boolean); 31 1 2 2 32 1 2 2 var i: integer; 33 1 2 3 ch: char; 34 1 2 4 35 1 3 1 procedure get_date(var date_to_set : date); 36 1 3 0 0 begin 37 1 3 1 0 with date_to_set do 38 1 3 2 5 begin 39 1 3 3 7 repeat 40 1 3 4 9 readln(i); 41 1 3 4 30 case i of 42 1 3 4 37 1: month := jan; 2: month := feb; 3: month := mar; 43 1 3 4 58 4: month := apr; 5: month := may; 6: month := jun; 44 1 3 4 79 7: month := jul; 8: month := aug; 9: month := sep; 45 1 3 4 100 10: month := oct; 11: month := nov; 12: month := dec; 46 1 3 4 121 end {case}; 47 1 3 4 152 if (i< 1) or (i> 12) then write('Bad date.. Try again: '); 48 1 3 3 202 until i in [1..12]; 49 1 3 3 214 write(' DAY: '); 50 1 3 3 252 repeat PASCAL-80 Compiler V2.1 SEEKEX.PAS Page: 2 Line Seg Proc Lev Disp 51 1 3 4 254 readln(i); 52 1 3 4 275 if (i< 1) or (i> 31) then write('Bad date.. Try again: '); 53 1 3 3 325 until i in [1..31]; 54 1 3 3 340 day := i; 55 1 3 3 352 write(' YEAR: '); 56 1 3 3 391 readln(year); 57 1 3 2 412 end {with}; 58 1 3 0 414 end {get_date}; 59 1 3 0 432 60 1 2 0 0 begin {init_files} 61 1 2 1 0 if not only_one then rewrite(people, 'people.dat') 62 1 2 1 29 else seek(people, recnumber); 63 1 2 1 42 repeat 64 1 2 2 44 with people^ do 65 1 2 3 49 begin 66 1 2 4 51 writeln; 67 1 2 4 61 write('First name: '); 68 1 2 4 86 readln(input, name.first); 69 1 2 4 108 if not eof(input) then 70 1 2 5 121 begin 71 1 2 6 123 write('Last name: '); 72 1 2 6 147 readln(input, name.last); 73 1 2 6 169 write('S.S. number: '); 74 1 2 6 195 readln(input,ssnum); 75 1 2 6 216 repeat 76 1 2 7 218 write('M(ale) or F(emale): '); 77 1 2 7 251 readln(input, ch); 78 1 2 7 271 case ch of 79 1 2 7 276 'M','m' : sex := male; 80 1 2 7 285 'F','f' : sex := female; 81 1 2 7 294 end; 82 1 2 6 382 until ch in ['M','m','F','f']; 83 1 2 6 406 writeln; 84 1 2 6 416 write('Input birth date... MONTH: '); 85 1 2 6 456 get_date (birth); 86 1 2 6 463 writeln; 87 1 2 6 473 write('Number of dependents: '); 88 1 2 6 508 readln(input, dependents); 89 1 2 6 529 write('Amount of money owed: '); 90 1 2 6 564 readln(input, debts); 91 1 2 6 585 repeat 92 1 2 7 587 write('Marital Status-- [M(arried), S(ingle), '); 93 1 2 7 639 write('D(ivorced), W(idowed)]: '); 94 1 2 7 676 readln(input, ch); 95 1 2 7 696 case ch of 96 1 2 7 701 'M','m': begin 97 1 2 9 703 marital_status := married; 98 1 2 9 710 write('Input date married .. MONTH: '); 99 1 2 9 752 get_date(date_married); 100 1 2 8 759 end; 101 1 2 7 763 'S','s': begin 102 1 2 9 765 marital_status := single; 103 1 2 9 772 independent := true; 104 1 2 8 779 end; PASCAL-80 Compiler V2.1 SEEKEX.PAS Page: 3 Line Seg Proc Lev Disp 105 1 2 7 783 'D','d': begin 106 1 2 9 785 marital_status := divorced; 107 1 2 9 792 first_divorse := true; 108 1 2 9 799 write('Input date divorced .. MONTH: '); 109 1 2 9 842 get_date(date_divorsed); 110 1 2 8 849 end; 111 1 2 7 853 'W','w': begin 112 1 2 9 855 marital_status := widowed; 113 1 2 9 862 write('Input date married .. MONTH: '); 114 1 2 9 904 get_date(date_married); 115 1 2 8 911 end; 116 1 2 7 915 end {case}; 117 1 2 6 1026 until ch in ['M','m','S','s','D','d','W','w']; 118 1 2 6 1052 allocated := true; 119 1 2 6 1057 put(people); 120 1 2 6 1066 writeln; 121 1 2 5 1076 end; 122 1 2 3 1078 end {with}; 123 1 2 1 1080 until eof(input) or only_one; 124 1 2 1 1094 if not only_one then close(people); 125 1 2 0 1110 end {initfile}; 126 1 2 0 1136 127 1 4 3 function display (a_record: integer) : boolean; 128 1 4 4 129 1 5 1 procedure print_date (date_to_print: date); 130 1 5 0 0 begin 131 1 5 1 0 with date_to_print do 132 1 5 2 8 begin 133 1 5 3 11 writeln(ord(month)+1:0,'/',day:0,'/',year:0); 134 1 5 2 74 end {with}; 135 1 5 0 77 end {print_date}; 136 1 5 0 92 137 1 4 0 0 begin {display} 138 1 4 1 0 seek(people, a_record); 139 1 4 1 11 get(people); 140 1 4 1 21 with people^, name do 141 1 4 2 32 begin 142 1 4 3 35 if eof(people) or not allocated then 143 1 4 4 51 begin 144 1 4 5 54 display := false; 145 1 4 5 60 exit(display); 146 1 4 4 67 end; 147 1 4 3 70 display := true; 148 1 4 3 76 writeln; 149 1 4 3 87 writeln; 150 1 4 3 98 writeln(first,' ',last); 151 1 4 3 141 case sex of 152 1 4 3 149 male: writeln('Male'); 153 1 4 3 177 female: writeln('Female'); 154 1 4 3 207 end {case}; 155 1 4 3 218 writeln('Social security number : ', ssnum:0); 156 1 4 3 277 write('Birth date : '); 157 1 4 3 304 print_date(birth); 158 1 4 3 312 writeln('Number of dependents : ', dependents:0); PASCAL-80 Compiler V2.1 SEEKEX.PAS Page: 4 Line Seg Proc Lev Disp 159 1 4 3 369 writeln('Debts : ', debts:0); 160 1 4 3 411 case marital_status of 161 1 4 3 419 married: begin 162 1 4 5 422 write('Married on : '); 163 1 4 5 449 print_date(date_married); 164 1 4 4 457 end; 165 1 4 3 462 widowed: begin 166 1 4 5 465 write('Widowed, married on : '); 167 1 4 5 501 print_date(date_married); 168 1 4 4 509 end; 169 1 4 3 514 divorced: begin 170 1 4 5 517 write('Divorced on : '); 171 1 4 5 545 print_date(date_divorced); 172 1 4 4 553 end; 173 1 4 3 558 single: writeln('Single'); 174 1 4 3 588 end {case}; 175 1 4 2 604 end {with}; 176 1 4 1 607 writeln; 177 1 4 1 618 writeln; 178 1 4 0 629 end {display}; 179 1 4 0 648 180 1 1 0 0 begin 181 1 1 1 0 reset(people,'people.dat'); 182 1 1 1 32 repeat 183 1 1 2 35 writeln; 184 1 1 2 46 write('Display which record [Enter number] : '); 185 1 1 2 98 readln(recnumber); 186 1 1 2 119 if not eof(input) then 187 1 1 3 133 if display(recnumber) then 188 1 1 4 144 begin 189 1 1 5 147 write('Do you wish to change this record? '); 190 1 1 5 196 readln(ch); 191 1 1 5 217 if ch in ['y','Y'] then initfile (true); 192 1 1 4 250 end 193 1 1 3 253 else writeln('NO SUCH RECORD'); 194 1 1 1 291 until eof(input); 195 1 1 0 304 end. PASCAL-80 Compiler V2.1 SEEKEX.PAS Page: 5 Procedure/Function Statistics: Name P/F Seg Proc Lev Param Size Local Vars Total Data Code Size GETDATE P 1 3 2 2 2 16 432 INITFILE P 1 2 1 2 6 20 1136 PRINTDAT P 1 5 2 2 6 20 92 DISPLAY F 1 4 1 6 4 22 648 DEMOSEEK P 1 1 0 4 114 130 330 Symbol table space remaining : 13570 bytes 195 lines compiled No errors detected