Advertisement
Guest User

Untitled

a guest
May 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.90 KB | None | 0 0
  1.  //Open file first
  2.   iFile := FSOpenFile( sFile, false );
  3.  
  4.   //Reset some vars
  5.   iQuestions := 0;
  6.   bCanStartGame := false;
  7.  
  8.   //File empty
  9.   if FSGetLinesCount( iFile ) < 0 then exit;
  10.  
  11.   //Read Q and A.
  12.   for iNr := 0 to FSGetLinesCount( iFile ) - 1 do
  13.   begin
  14.       sContent := FSReadLine ( iFile, iNr );
  15.  
  16.       //Reset table before
  17.       TQuestions[iNr] := '';
  18.       TAnswers[iNr] := '';
  19.  
  20.       //Copy contents
  21.       TContent := Split ( sContent, '*' );
  22.  
  23.       //Save Q & A
  24.       TQuestions[iNr] := TContent[0];
  25.       TAnswers[iNr] := TContent[1];
  26.  
  27.       //Increment questions
  28.       iQuestions := iQuestions + 1;
  29.       Log ( IntToStr ( iQuestions ) );
  30.   end;
  31.  
  32.    //Check
  33.    if iQuestions > 1 then
  34.    begin
  35.       sFileName := sFile;
  36.       bCanStartGame := true;
  37.    end;
  38.  
  39.    //Notify
  40.    Log ( '[TRIVIA] Loaded a total of ' + IntToStr ( iQuestions ) + ' questions and answers!' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement