This is cheating.
OK, so it's not that bad - but I want you to create the code on your own. Anyway here's an example of what it might look like.
var
Form3: TForm3;
qFile :Textfile;
questionArray: Array[1..100] of string;
answerArray:Array[1..5,1..100] of string;
noOfAnswers:Array[1..100] of integer;
rightAnswer:Array[1..100] of integer;
implementation
{$R *.dfm}
procedure splitMeUp(qLine:string;qNumber:integer);
var
charcounter : integer;
whichbit : integer;
stringreader: string;
thischar : char;
begin
whichbit := 0;
stringreader := '';
for charcounter := 1 to length(qLine) do
begin
thischar := qLine[charcounter];
if thischar = ',' then begin
if whichbit = 0 then
noOfAnswers[qNumber] := strtoint(stringreader);
if whichbit = 1 then
rightAnswer[qNumber] := strtoint(stringreader);
if whichbit = 2 then
questionArray[qNumber] := stringreader;
if whichbit > 2 then
answerArray[whichbit-2,qNumber] := stringreader;
whichbit := whichbit+1;
stringreader := '';
end else begin
stringreader := stringreader+thischar;
end;
end;
end;
procedure analyzeLines(filename:string);
var
questionCounter :integer;
whichbit :integer;
tempstring :string;
whichfile :Textfile;
begin
assign(whichfile,filename);
reset(whichfile);
questionCounter := 1;
whichbit := 0;
while not eof(whichfile) do
begin
readln(whichfile,tempstring);
whichbit := whichbit+1;
if whichbit > 8 then begin
whichbit := 1;
questionCounter := questionCounter + 1;
end;
if whichbit = 1 then
noOfAnswers[questionCounter] := strtoint(tempstring);
if whichbit = 2 then
rightAnswer[questionCounter] := strtoint(tempstring);
if whichbit = 3 then
questionArray[questionCounter] := tempstring;
if whichbit > 3 then
answerArray[whichbit-3,questionCounter] := tempstring;
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
var
qandAstring : string;
questionCounter : integer;
begin
{ // section for unstructured multi-line file
analyzeLines('N:\lineanswers.txt');}
{ // section for single line file
AssignFile(qFile, 'N:\lineanswers.txt');
while not EOF(qfile) do
begin
readln(qfile,qandAstring);
questionCounter := questionCounter + 1;
splitMeUp(qandAstring,questionCounter);
memo1.Lines.Add(questionArray[questionCounter]);
end;
}
memo1.Lines.Add('Done');
end;
end.