problems with alternatives

Hi again! I still got problem with my simple game when I want to create another TStringList to change the radiobuttons alternatives =((

my code is as follows:
I get some exception out of bounds,,,,some one have any simple idea I would be greatful

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FQuestions: TStringList;
FAlternatives : TStringList;

FCurrentQuestion : integer;

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
FQuestions := TStringList.Create;
FAlternatives := TStringList.Create;
FQuestions.LoadFromFile('c:question.txt');
FCurrentQuestion := 0;

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
FQuestions.Free;
FAlternatives.Free;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

FAlternatives := 'olle','tyke;
inc(FCurrentQuestion);
Memo1.Text := FQuestions[FCurrentQuestion];
RadioGroup1.Items.CommaText := FAlternatives[FCurrentQuestion];

end;

end.

Comments

  • : Hi again! I still got problem with my simple game when I want to create another TStringList to change the radiobuttons alternatives =((
    :
    : my code is as follows:
    : I get some exception out of bounds,,,,some one have any simple idea I would be greatful
    :
    : unit Unit1;
    :
    : interface
    :
    : uses
    : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    : Dialogs, StdCtrls, ExtCtrls;
    :
    : type
    : TForm1 = class(TForm)
    : Button1: TButton;
    : Memo1: TMemo;
    : RadioGroup1: TRadioGroup;
    : RadioButton1: TRadioButton;
    : RadioButton2: TRadioButton;
    : procedure FormCreate(Sender: TObject);
    : procedure FormDestroy(Sender: TObject);
    : procedure Button1Click(Sender: TObject);
    : private
    : FQuestions: TStringList;
    : FAlternatives : TStringList;
    :
    : FCurrentQuestion : integer;
    :
    : { Private declarations }
    : public
    : { Public declarations }
    : end;
    :
    : var
    : Form1: TForm1;
    :
    : implementation
    :
    : {$R *.dfm}
    :
    : procedure TForm1.FormCreate(Sender: TObject);
    : begin
    : FQuestions := TStringList.Create;
    : FAlternatives := TStringList.Create;
    : FQuestions.LoadFromFile('c:question.txt');
    : FCurrentQuestion := 0;
    :
    : end;
    :
    : procedure TForm1.FormDestroy(Sender: TObject);
    : begin
    : FQuestions.Free;
    : FAlternatives.Free;
    :
    : end;
    :
    : procedure TForm1.Button1Click(Sender: TObject);
    : begin
    :
    : FAlternatives := 'olle','tyke;
    : inc(FCurrentQuestion);
    : Memo1.Text := FQuestions[FCurrentQuestion];
    : RadioGroup1.Items.CommaText := FAlternatives[FCurrentQuestion];
    :
    : end;
    :
    : end.
    :
    :
    The FAlternative list is still empty. I would suggest that you place the alternatives in another text file, which is read by the program, much like the way the questions is handled.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion