
12.02.2011, 00:02
|
Прохожий
|
|
Регистрация: 10.03.2007
Сообщения: 1
Репутация: 10
|
|
привязка событий по времени
в тхт файле содержится расписание в виде:
1
зарядка
07:00
07:30
2
прием пищи
08:00
08:30
в форме имеется 6 полей(memo) в первых 3-х выводится текущее действие и его временные интервалы. в остальных выводится предстоящее действие в с временными интервалами
также имеются часы.
помогите написать код для осуществления данной задачи
Код:
procedure TForm2.Timer2Timer(Sender: TObject);
var x:integer;
begin
{Первая мемо}
if filebuffer.stringgrid3.cells[0,1]<>'' then
for x:=1 to 43 do
if obsh_vrm>strtoint(filebuffer.StringGrid3.Cells[0,x]) then
begin
memo8.Text:=filebuffer.StringGrid2.Cells[2,x];
memo9.Text:=filebuffer.StringGrid2.Cells[3,x];
memo4.Text:=filebuffer.StringGrid2.cells[2,x+1];
memo5.Text:=filebuffer.StringGrid2.cells[3,x+1];
if Memo4.Text='99.99' then Memo4.Text:=' ';
if Memo5.Text='99.99' then Memo5.Text:=' ';
if Memo8.Text='99.99' then Memo8.Text:=' ';
if Memo9.Text='99.99' then Memo9.Text:=' ';
end;
end;
Код:
unit Unit13;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ValEdit, ExtCtrls, StdCtrls, ComCtrls;
type
Tfilebuffer = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Button1: TButton;
ProgressBar1: TProgressBar;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
filebuffer: Tfilebuffer;
i:integer;
o:integer;
txt:string;
txt2:integer;
f:textfile;
s:string;
fff:string;
ii:string;
ll:string;
nn:string;
mm:integer;
implementation
{$R *.dfm}
procedure Tfilebuffer.FormCreate(Sender: TObject);
begin
stringgrid1.Cells[0,0]:='Наименование';
stringgrid1.Cells[1,0]:='Значение';
stringgrid2.Cells[0,0]:='№';
stringgrid2.Cells[1,0]:='Наименование мероприятия';
stringgrid2.Cells[2,0]:='Начало';
stringgrid2.Cells[3,0]:='Конец';
stringgrid3.Cells[0,0]:='Сумма';
end;
procedure Tfilebuffer.FormActivate(Sender: TObject);
var mm:Integer;
begin
if filebuffer.stringgrid1.Cells[0,1]<>'' then
begin
i:=0;
o:=1;
txt:='';
txt2:=0;
fff:='';
ii:='';
ll:='';
nn:='';
begin
AssignFile(F,filebuffer.stringgrid1.Cells[1,1]);
Reset(F);
while not Eof(F) do
begin
Readln(F,S);
stringgrid2.Cells[i,o]:=S;
i:=i+1;
if i=4 then
begin
i:=0;
o:=o+1;
end;
if S='' then
i:=i-1;
end;
CloseFile(F);
filebuffer.Stringgrid2.RowCount:=o+1;
filebuffer.StringGrid2.Cells[i,o]:=filebuffer.stringgrid2.Cells[1,1];
filebuffer.StringGrid2.Cells[i+1,o]:=filebuffer.stringgrid2.Cells[2,1];
filebuffer.StringGrid2.Cells[i+2,o]:=filebuffer.stringgrid2.Cells[3,1];
end;
end;
stringgrid3.rowcount:=stringgrid2.rowcount;
for mm:=1 to stringgrid3.rowcount do
if stringgrid2.Cells[2,mm]<>'' then
begin
ii:=stringgrid2.Cells[2,mm];
nn:=ii[1]+ii[2];
ll:=ii[4]+ii[5];
stringgrid3.Cells[0,mm]:=inttostr(strtoint(nn)*60+strtoint(ll));
end;
end;
procedure Tfilebuffer.Timer1Timer(Sender: TObject);
begin
progressbar1.Position:=progressbar1.Position+20;
if progressbar1.Position>=100 then
filebuffer.Visible:=false;
end;
end.
вот кусок кода. если надо что-то еще, пиши
|