I am trying to write a routine that will take informtion from one data file and write consecutive records to another file based on dates and number of days.
For example:
1. The user will enter two dates
2. After posting the entry
The routine needs to write a seperate record
for each date from the first to the end date
that the user entered.
I've never really had to do a "FOR" statement and had no success with the following code. Can someone tell me how this actually works and what some simple rules are?
[tt]
procedure TForm1.Button2Click(Sender: TObject);
var i, j : integer;
var n :string;
var d : TDateTimeField;
begin
tbNamesDays.Value := tbNamesOutDate.Value - tbNamesInDate.value;
n := tbNamesName.Value;
d := tbNamesInDate;
j := tbNamesDays.AsInteger;
tbNames.Post;
for i := 1 to 7 do
begin
tbBlock.Insert;
tbBlockName.Value := n;
tbBlockBlockDate.Value := d.Value;
tbBlock.Post;
d.AsFloat := d.AsFloat + 1;
end;
end;
[/tt]
Aloha,
cg
For example:
1. The user will enter two dates
2. After posting the entry
The routine needs to write a seperate record
for each date from the first to the end date
that the user entered.
I've never really had to do a "FOR" statement and had no success with the following code. Can someone tell me how this actually works and what some simple rules are?
[tt]
procedure TForm1.Button2Click(Sender: TObject);
var i, j : integer;
var n :string;
var d : TDateTimeField;
begin
tbNamesDays.Value := tbNamesOutDate.Value - tbNamesInDate.value;
n := tbNamesName.Value;
d := tbNamesInDate;
j := tbNamesDays.AsInteger;
tbNames.Post;
for i := 1 to 7 do
begin
tbBlock.Insert;
tbBlockName.Value := n;
tbBlockBlockDate.Value := d.Value;
tbBlock.Post;
d.AsFloat := d.AsFloat + 1;
end;
end;
[/tt]
Aloha,
cg