bonsoir tous le monde
sur delphi 2010 entreprise j'ai une erreur quand je veux séparer un text '|' par cette Function
merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56function TQuizUnit.LoadQuizFromFile(const FileName: string): Boolean; var SL: TStringList; i,j: Integer; Line: string; Question: TQuestion; AnswerText: string; AnswersArray: TArray<string>; begin Result := False; SL := TStringList.Create; try SL.LoadFromFile(FileName); i := 0; while i < SL.Count do begin // Read Question Text Line := Trim(SL[i]); if Line = '' then begin Inc(i); Continue; end; Question := TQuestion.Create; Question.QuestionText := Line; Inc(i); // Read Answers if i < SL.Count then begin Line := Trim(SL[i]); // l'erreur ce produit ici 2018 Type record , object ou class requis + identificateur non déclarer TStringSplitOptions AnswersArray := Line.Split(['|'], TStringSplitOptions.ExcludeEmpty); for j := Low(AnswersArray) to High(AnswersArray) do begin AnswerText := Trim(AnswersArray[j]); if StartsText('*', AnswerText) then begin Question.CorrectAnswerIndex := Question.Answers.Count; AnswerText := Copy(AnswerText, 2, Length(AnswerText) - 1); // Remove '*' end; Question.Answers.Add(AnswerText); end; Inc(i); end; FQuestions.Add(Question); end; Result := True; finally SL.Free; end; end;
.







Répondre avec citation
Partager