Hi,
Sorry and thanks, I am here with this stupid error I don't trieve.. I am a real idiot.
procedure TForm3.Demarrer_Session;
var i: integer;
begin
nreponses :=0;
try
xls := TexcelFile.Create; // xls is declared in the general section - never used before
// if xls is declared locally the error is the same
xls.Open('c:\examen_delphi\Questions_delphi_mod2.xlsx'); // all cells as Standard
xls.AllowOverwritingFiles := true;
xls.ActiveSheet:=1;
xls.Sort(
TXlsCellRange.Create(2, 1, xls.RowCount, xls.ColCountOnlyData),
true, //Normally we want to sort the rows in the range. But we might want to sort columns and we can do it by setting this to false.
Int32Array.Create(12, 3), // Sort by columns B and C (12 and 3)
nil,
nil,
TSortFormulaMode.ExcelLike // Use the standard comparer.
);
i:= 2;
Repeat
if (xls.GetCellValue(i, 12)<'201') then Inc(i); // debugging, this line is never executed
until (xls.GetCellValue(i,12)='201');
while (i<=xls.RowCount) do begin
if xls.GetCellValue(i,12)='201' then begin
Inc(nreponses);
Poser_Question(i); // actually only showing the questions ; uses xls without modifying it
sleep(2000);
end;
Inc(i);
end;
finally
Stopper_Session;
xls.Free;
Close;
end;
end;
Obviously, that is "Poser_Questions" that is important, I have to use it 2 times for each family as '201', '202', until "210" and the questions are ended when a time gives 30 minutes for the 20 questions, counting then the score - thus adding more habitual features, as going through the 20 questions, a timer, aso.
But if I can't first fill an array of 20 questions looking as randomly chosen (that's why I want to start on a CRC32 in the second place), do some trivial sort as a Shell-Metzner on this array and CRC32 to avoid showing each family after the other, ..
Actually, I can set a break point anywhere in the code, it is never reached. I add an image of the error I got yesterday, the code was modified following your advices but the result is the same.
Here I declared xls in the general variables, but if i do it inside the procédure it's the same.
The Excel File was filled with CRC32 and the location of each picture (of the questions) in another program, so here all I do is reading it, I doesn't have to write the file when it is sorted. If it helps I can too sort this file in the previous program, if doesn't matter as the present program is only to be used
to simulate the exam.