This is giving me an error and im not sure why?
procedure BeginSort;
var I, X: Integer;
begin //(1) whole thing
Sorted:= false;
repeat
begin //(2)
For I := 1 to 30 do
Begin //(3)
If Question[I].position > Question[I+1].position then
Begin //(4) for if the question position is higher
TempQuestionText:= Question[I].QuestionText; //sets the temporary question value to the current question value of the first question
Question[I].QuestionText:= Question[I+1].QuestionText; //makes the value of the first the value of the second
Question[I+1].QuestionText:= TempQuestionText; //sets the value of the second question value to the one which is now in temporary (the first)
//they are now swapped
TempAnswer:= Question[I].Answer;
Question[I].Answer:= Question[I+1].Answer;
Question[I+1].Answer:= TempAnswer;
TempMultibleChoiceA:= Question[I].MultibleChoiceA;
Question[I].MultibleChoiceA:= Question[I+1].MultibleChoiceA;
Question[I+1].MultibleChoiceA:= TempMultibleChoiceA;
TempMultibleChoiceB:= Question[I].MultibleChoiceB;
Question[I].MultibleChoiceB:= Question[I+1].MultibleChoiceB;
Question[I+1].MultibleChoiceB:= TempMultibleChoiceB;
TempMultibleChoiceC:= Question[I].MultibleChoiceC;
Question[I].MultibleChoiceC:= Question[I+1].MultibleChoiceC;
Question[I+1].MultibleChoiceC:= TempMultibleChoiceC;
TempMultibleChoiceD:= Question[I].MultibleChoiceD;
Question[I].MultibleChoiceD:= Question[I+1].MultibleChoiceD;
Question[I+1].MultibleChoiceD:= TempMultibleChoiceD;
TempMultibleChoice:= Question[I].MultibleChoice;
Question[I].MultibleChoice:= Question[I+1].MultibleChoice;
Question[I+1].MultibleChoice:= TempMultibleChoice;
TempPosition:= Question[I].Position;
Question[I].Position:= Question[I+1].Position;
Question[I+1].Position:= TempPosition;
End; //(4) for if the question position is higher
End; //(3) 1-30 loop
//this bit now checks if its been completely sorted
For X := 1 to 30 do
begin
if Question[X].Position <> X then
Sorted:= false
else if Question[X].Position = 30 then
Sorted:= true
else
Sorted:= False
end
end
until Sorted = true;
end; //(1) whole thing