Registriert seit: 24. Mär 2006
16 Beiträge
|
Re: speichern von var
26. Mär 2006, 21:50
Delphi-Quellcode:
unit umfrage;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniFiles;
type
TForm1 = class(TForm)
Label1: TLabel;
choosedrg: TRadioGroup;
votebtm: TButton;
procedure votebtmClick(Sender: TObject);
procedure FormShow(sende:TObject);
private
Fini:TIniFile:
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
a,b,c,d,e,f,ap,bp,cp, dp,ep,fp,x:double;
implementation
{$R *.dfm}
procedure TForm1.Form1Create(sender:TObject);
begin
Fini := TIniFile.Create(ExtractFilepath(paramstr(0)+' ergebnis.ini');
a:=ini.ReadFloat(' frage1',' wert1',0);
b:=ini.ReadFloat(' frage1',' wert2',0);
c:=ini.ReadFloat(' frage1',' wert3',0);
d:=ini.ReadFloat(' frage1',' wert4',0);
e:=ini.ReadFloat(' frage1',' wert5',0);
f:=ini.ReadFloat(' frage1',' wert6',0);
end;
procedure TForm1.votebtmClick(Sender: TObject);
begin
case choosedrg.ItemIndex of
0:a:=a+1;
1:b:=b+1;
2:c:=c+1;
3:d:=d+1;
4:e:=e+1;
5:f:=f+1;
end;
x:=a+b+c+d+e+f;
ap:=a*100/x;
bp:=b*100/x;
cp:=c*100/x;
dp:=d*100/x;
ep:=e*100/x;
fp:=f*100/x;
ini:=TIniFile.create(ExtractFilePath (ParamStr(0))+' ergebnis.ini');
ini.WriteFloat(' frage1', ' wert1', a);
ini.WriteFloat(' frage1', ' wert2', b);
ini.WriteFloat(' frage1', ' wert3', c);
ini.WriteFloat(' frage1', ' wert4', d);
ini.WriteFloat(' frage1', ' wert5', e);
ini.WriteFloat(' frage1', ' wert6', f);
end;
procedure TForm1.Form1Destroy(Sender: TObject);
begin
FreeAndNil(Fini);
end;
end.
müsste dies dann so ausseheb?
|