hi experts
I am now writing a procedure for my main program in order to let people search for their required entries (eg. user inputs name and the program returns the name together with the tel no. etc.) The procedure is now in its simplest state as users can only search with names of records. but things still go wrong as I think there's some kind of logical error in this procedure, whatever you input, even if there really is the record with the exact structure, it still returns me with the statement 'Data not found! Search abandoned.'
well I hope you do understand what I mean... pardon me for my clumsy english...

Procedure SearchEntry;
var
   target : string;
   found : boolean;
begin
     ReadFile; {there is a procedure named ReadFile for reading data from text file into a 2-D array}
     write('Please enter name to be searched: ');
     readln(target); {user inputs required name}
     i := 1;
     found := false; 
     target := target + '                              ';
     while (DetailsInfo[i,'A'] <> '') and not found do {DetailsInfo[i,'A'] is the place where all the names of the records are stored in the 2-D array}
        begin
           if DetailsInfo[i,'A'] = target
           then found := true
           else i:= i+1
        end;
     if found
        then  begin
                writeln; {just for the sake of making the program more presentable}
                writeln('Name               Tel. Number     Email Address                 Group');
                writeln('------------------------------------------------------------------------');
                writeln(DetailsInfo[i,'A'],DetailsInfo[i,'B'],DetailsInfo[i,'C'],DetailsInfo[i,'D']); {get this one right? this prints the search results out from the 2-D array}
                writeln;
              end 
        else writeln('Data not found! Search abandoned.')
end;

I think the problem with my program now is that it is unable to change the status of 'found' to true only, and everything basically works all right..
would anybody be kind enough to help please ?
thanks in advance.

the main algorithm of the shearching..... :D

(*
found:=false;
i:=0;
while (i <= N) and (found = false) do begin
    i:=i+1;
    reach the i. element;
    found:=i. element's property;
end;
*)
(*or if we don't know the number of the elements*)
(*
found:=false;
i:=0;
reach the i. element +1;
while (there are elements) and (found = false) do begin
    i:=i+1;
    found:=i.element's property;
    if found = false then reach the i. element+1;
end;
*)
(*
or if the elements are unlimited ,and we search while found = true*)
(*
found:=false;
i:=0;
repeat
    i:=i+1;
    reach i. element;
    found:= i. element's propery;
until found = true;

*)
(*I hope I could help to you*)
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.