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

hey why hasnt anyone replied? If theres someone who can help I would really appreciate it thanks

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,

where do i need to strat my loop and where to stop it ?

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,

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

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,

thanks alot it worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.