I've solved the issue of entering text into a TMemo but have spent two days trying to put that data into a DBrecord.
[...]
Type
Event = record
D : Date;
T : Time;
Alarm : TDatetime;
Desc : array[1..2] of string[64];
Loc : string[64];
Rep : byte;
Mis : boolean;
Ack : boolean;
end;
[...]
Events : Array[1..30] of Event;
[...]
procedure Tclock.SaveButtonClick(Sender: TObject); // EVENT SAVE Button
Var
Adj, T, Alarm_Time : TDateTime;
begin
clock.err_mess.visible := false;
case EvAlarm.Itemindex of
0 : Adj := 1/96; // 15 minutes
1 : Adj := 1/48; // 30 minutes
2 : Adj := 1/24; // 1 hour
3 : Adj := 1/12; // 2 hours
end;
Alarm_Time := EvDate.date+EvTime.time - Adj;
T := Now;
if Alarm_Time < T then
begin
err_Mess.caption := 'Alarm time has already passed - re-enter date-time or cancel';
clock.err_mess.visible := true;
end
else
begin
extract_date(EvDate.date+EvTime.time);
with Diary_Event do
begin
D := Cur_Date;
T := Cur_Time;
Alarm := Alarm_Time;
Desc[1] := clock.EvDesc.lines[1]; // 'clock.' added in case it made a difference
Desc[2] := clock.EvDesc.lines[2]; // it didn't !!
Loc := EvWhere.text;
Rep := 0;
Mis := false;
Ack := false;
end;
save_Event;
Clear_EventForm;
end;
end;
EvDesc is a TMemo - I don't expect it to handle more than two lines.
All the other fields accept the correct information (Loc is a TEdit - D & T are my own 'types') but on the first run of the data entry form 'Desc[1] and Desc[2] BOTH get whatever I enter into the top line of the TMemo with the first character replaced by '#10'. On subsequent runs they are both empty.
Error handling works as expected and I've worked out how to extract the date and time from TDateEdit and TTimeEdit components - but I can't see what I can change to make the event description accept what I enter.