SRL Archive - OSR Help

Why is this a type mismatch?


rj

2013-06-09 21:11:49

I am trying to use a TTimer.. but I'm getting a type mismatch for some reason. This example is ripped right off of @Daniel's Form tutorial.

var
frmMain: TForm;
Params: TVariantArray;
timerUpdate:TTimer;

procedure OnTimeUp(Sender: TObject);
begin
Writeln('5 seconds have passed!');
end;

procedure InitialiseForm;
begin
frmMain := TForm.Create(nil);
frmMain.Show;
begin
timerUpdate := TTimer.Create(frmMain);
timerUpdate.INTERVAL := 5000;
timerUpdate.Enabled := True;
timerUpdate := @OnTimeUp;
end;
end;

begin
ThreadSafeCall('InitialiseForm', Params);
frmMain.Close;
frmMain.Free;
end.

Type mismatch at this line:

timerUpdate := @OnTimeUp;

Awkwardsaw

2013-06-09 21:42:00

.ontimer needs to be added :)

rj

2013-06-09 23:16:09

From: Awkwardsaw
.ontimer needs to be added :)


var
frmMain: TForm;
Params: TVariantArray;
timerUpdate:TTimer;

procedure OnTimeUp(Sender: TObject);
begin
Writeln('5 seconds have passed!');
end;

procedure InitialiseForm;
begin
frmMain := TForm.Create(nil);
frmMain.Show;
begin
timerUpdate := TTimer.Create(frmMain);
timerUpdate.INTERVAL := 5000;
timerUpdate.Enabled := True;
timerUpdate.ONTIMER := @OnTimeUp;
end;
end;

begin
ThreadSafeCall('InitialiseForm', Params);
frmMain.Close;
frmMain.Free;
end.

that just crashes simba lol

Le Jingle

2013-06-10 01:21:11

I believe what you are questioning can be found here:
http://villavu.com/forum/showthread.php?t=3664
(Freddy's Forms TTimer tutorial)