Hi there ppl I have a problem with my prog, the problem is that it doesn't store anything in my desired record plz help thanks
HERE'S THE PROG BELOW
Code:Program Boat_Rental (input,output); Uses winCRT; Type cos_info = Record name:String; phone:Integer; address:String; End; Var cos_file: file of cos_info; big,med,small,boatno,counter:integer; cos:string; name,phone,address,choice1:string; boat1,smallfile,bigfile,medfile:text; customer:cos_info; Procedure checkinb; { This is the check in section } Begin { } writeln ('Enter customers name'); { } readln (cos); { } End; { } { } { } Procedure checkinm; { } Begin { } writeln ('Enter customers name'); { } readln (cos); { } End; { } { } Procedure checkins; { } Begin { } writeln ('Enter customers name'); { } readln (cos); { I don't know how to search } End; { } { } Procedure checkin; { } Var { } choice:string; { } Begin { } writeln ('Press 1 to checkin SMALL boats'); { } writeln ('Press 2 to checkin MEDIUM boats'); { } writeln ('Press 3 to checkin BIG boats'); { } If choice = '1' Then { } checkins { } Else IF choice = '2' Then { } checkinm { } Else IF choice = '3' Then { } checkinb { So I can't do this part yet } Else { } checkin; { } End; { } Procedure write_to_file; Var boo:string; Begin writeln (customer.name,name); { <----- This is where it writes down customer info} writeln (customer.phone,phone); {I've only done it for 1 boat} writeln (customer.address,address); rewrite (cos_file); write (cos_file,customer); close (cos_file); End; Procedure checkouts; Begin clrscr; {Input of customer necessaries 4 small} writeln ('Enter name of customer: '); readln (name); writeln ('Enter phone number of customer: '); readln (phone); writeln ('Enter address of customer: '); readln (address); small:= small-1; boatno:= small+1; write_to_file; End; Procedure checkoutm; Begin clrscr; {4 medium} writeln ('Enter name of customer: '); readln (name); writeln ('Enter phone number of customer: '); readln (phone); writeln ('Enter address of customer: '); readln (address); med:= med-1; boatno:= med+1; End; Procedure checkoutb; Begin clrscr; writeln ('Enter name of customer: '); {and 4 big} readln (name); writeln ('Enter phone number of customer: '); readln (phone); writeln ('Enter address of customer: '); readln (address); big:= big-1; boatno:= big+1; End; Procedure checkers; {checks to see if there are any available boats 4 small} Begin If small = 0 Then writeln ('There are no more boats available') Else If small >0 Then checkouts; End; Procedure checkerm; Begin If med = 0 Then {also 4 medium} writeln ('There are no more boats available') Else If med >0 Then checkoutm; End; Procedure checkerb; Begin If big = 0 Then {and 4 big} writeln ('There are no more boats available') Else If big >0 Then checkoutb; End; Procedure checkout; Var {Menu choice between buying small, medium or big boats} choice:string; Begin clrscr; writeln ('Press 1 to checkout SMALL boats'); writeln ('Press 2 to checkout MEDIUM boats'); writeln ('Press 3 to checkout BIG boats'); readln (choice); If choice = '1' Then checkers Else IF choice = '2' Then checkerm Else IF choice = '3' Then checkerb Else checkout; End; Procedure rental; Var choice:string; Begin clrscr; writeln ('Press 1 for checking IN boat'); writeln ('Press 2 for checking OUT boat'); readln (choice); IF choice = '1' Then checkin Else If choice = '2' Then checkout Else rental; End; Procedure inventory; Begin clrscr; writeln ('Small boats --- ',small); writeln ('Medium boats --- ',med); writeln ('Big boats --- ',big); writeln ('Press enter to go back to the menu'); readln; End; Procedure calculate; Begin clrscr; writeln ('CALCULATE'); readln; End; Procedure searcher; Begin writeln ('SEARCHER'); readln; End; Procedure draw; Begin reset (cos_file); read (cos_file,customer); End; Procedure welcome; Begin clrscr; writeln ('Press 1 to access rental system'); writeln ('Press 2 to access Inventory'); writeln ('Press 3 to aceess calulations profit,loss etc.'); writeln ('Press 4 to search for customer information'); writeln ('Press 5 to exit'); readln (choice1); clrscr; If choice1 = '1' Then rental Else If choice1 = '2' Then inventory Else If choice1 = '3' Then calculate Else If choice1 = '5' Then writeln ('Press ENTER to exit') Else If choice1 = '6' Then draw Else welcome; End; Procedure endprep; Begin rewrite (smallfile); rewrite (medfile); rewrite (bigfile); write (smallfile,small); write (medfile,med); write (bigfile,big); close (smallfile); close (medfile); close (bigfile); End; Procedure prep; Var changer:integer; Begin reset (smallfile); reset (medfile); reset (bigfile); read (smallfile,changer); small:=changer; read (medfile,changer); med:=changer; read (bigfile,changer); big:=changer; End; Begin assign (cos_file,'D:\sba\Small\recorder.txt'); assign (boat1,'D:\sba\Small\boat1.txt'); assign (smallfile,'D:\sba\Inventory\small.txt'); assign (medfile,'D:\sba\Inventory\medium.txt'); assign (bigfile,'D:\sba\Inventory\big.txt'); prep; Repeat welcome; Until choice1 = '5'; endprep; readln; donewincrt; End.
Last edited by WingedPanther; 01-11-2009 at 03:53 PM. Reason: add code tags (the # button)
Ignore all the necessary parenthesis there was an error with the copy and pasting :-)
Well, checkouts is the only procedure that calls write_to_file, which also closes its file. endprep also writes to file. Are you sure you are calling endprep and that your variables are getting updated?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks