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.