User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 456,421 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,629 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 2598 | Replies: 7 | Solved
Reply
Join Date: Jan 2007
Posts: 10
Reputation: exotic_ang is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
exotic_ang exotic_ang is offline Offline
Newbie Poster

Help Searching a record

  #1  
Jan 13th, 2007
hey im lost, so was wondering if anyone would help me. Im doing a program for a DVD rental system. When it comes to searching the rentals by ID, I cant seem to make it show all the DVD's that the customer has rented not only one. I dont know if I was clear enough so here's the procedure I wrote:

procedure SEARCH_RENTAL_ID (s:string);

begin
found := false;
seek(r,0);
if (filesize(r) = 0) then
writeln(' Currently there are no entries in this file')
else begin
while not(eof(r)) and (found = false) do
begin
read(r,rr);
if (rr.ID) = s then
begin
writeln;
writeln(' ID.................',rr.ID);
writeln;
writeln(' ISBN...............',rr.ISBN);
writeln;
writeln(' Rental Type........',rr.rental_type);
writeln;
writeln(' Date Out...........',rr.date_out);
writeln;
writeln(' Date In............',rr.date_in);
found := true;
end;
end;
if found = false then
begin
textcolor(yellow+blink);
writeln;
writeln;
writeln(' *** HAS NO RENTALS YET ***');
textcolor(yellow);
end;
end;
end;

the only thing I need I suppose is a loop to display all the rentals the member has but I cant manage to do it. If anyone knows pls help me tnx
Last edited by exotic_ang : Jan 13th, 2007 at 8:18 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 10
Reputation: exotic_ang is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
exotic_ang exotic_ang is offline Offline
Newbie Poster

Re: Searching a record

  #2  
Jan 17th, 2007
hey why hasnt anyone replied? If theres someone who can help I would really appreciate it thanks
Reply With Quote  
Join Date: Dec 2006
Location: Romania
Posts: 171
Reputation: radu84 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 16
radu84 radu84 is offline Offline
Junior Poster

Re: Searching a record

  #3  
Jan 19th, 2007
Originally Posted by exotic_ang View Post
hey im lost, so was wondering if anyone would help me. Im doing a program for a DVD rental system. When it comes to searching the rentals by ID, I cant seem to make it show all the DVD's that the customer has rented not only one. I dont know if I was clear enough so here's the procedure I wrote:

procedure SEARCH_RENTAL_ID (s:string);

begin
found := false;
seek(r,0);
if (filesize(r) = 0) then
writeln(' Currently there are no entries in this file')
else begin
while not(eof(r)) and (found = false) do
begin
read(r,rr);
if (rr.ID) = s then
begin
writeln;
writeln(' ID.................',rr.ID);
writeln;
writeln(' ISBN...............',rr.ISBN);
writeln;
writeln(' Rental Type........',rr.rental_type);
writeln;
writeln(' Date Out...........',rr.date_out);
writeln;
writeln(' Date In............',rr.date_in);
found := true;
end;
end;
if found = false then
begin
textcolor(yellow+blink);
writeln;
writeln;
writeln(' *** HAS NO RENTALS YET ***');
textcolor(yellow);
end;
end;
end;

the only thing I need I suppose is a loop to display all the rentals the member has but I cant manage to do it. If anyone knows pls help me tnx


the problem in your code is that when you find one rental you stop the loop. why? you need to get all the rentals no?
if you are unsure about what i'm saying try to run your code step by step, watch the variables and i'm sure you'll undestand

best regards,
Reply With Quote  
Join Date: Jan 2007
Posts: 10
Reputation: exotic_ang is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
exotic_ang exotic_ang is offline Offline
Newbie Poster

Re: Searching a record

  #4  
Jan 19th, 2007
where do i need to strat my loop and where to stop it ?
Reply With Quote  
Join Date: Dec 2006
Location: Romania
Posts: 171
Reputation: radu84 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 16
radu84 radu84 is offline Offline
Junior Poster

Re: Searching a record

  #5  
Jan 20th, 2007
have you tryed to do what i posted before?
i can give you the answer but this does not mean you will learn something. try to understand. if you still can't handle with this problem post again here and i will give you the answer, but the ideea still remain to understand your code.

best regards,
Reply With Quote  
Join Date: Jan 2007
Posts: 10
Reputation: exotic_ang is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
exotic_ang exotic_ang is offline Offline
Newbie Poster

Re: Searching a record

  #6  
Jan 20th, 2007
i tried using another while loop but i just messed all the program up. I dont know why ive written a whole project and cant manage to solve this simple problem
Reply With Quote  
Join Date: Dec 2006
Location: Romania
Posts: 171
Reputation: radu84 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 16
radu84 radu84 is offline Offline
Junior Poster

Re: Searching a record

  #7  
Jan 20th, 2007
try to take the programming step by step.
so, your while loop is working until either you find an record or you reach the eof.
while not(eof(r)) and (found = false) do
this should look while not eof(r)
in this way i think it should work.

best regards,
Reply With Quote  
Join Date: Jan 2007
Posts: 10
Reputation: exotic_ang is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
exotic_ang exotic_ang is offline Offline
Newbie Poster

Re: Searching a record

  #8  
Feb 9th, 2007
thanks alot it worked
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 1:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC