Re: Delphi Timer.Interval / cardinal value

Posted by DelphiLand Team

In Reply to: Timer.interval and cardinal value posted by Stefan Loeners

: My app reads the timer interval from an ini file.
: However, this value needs to be converted to a cardinal type.

: I tried ReadString and ReadInteger and then convert the value this way :
: Timer1.Interval:=cardinal(TimerValueReadFromIniFile)
: Any idea how it should be done?

You don't have to convert the integer value to a cardinal, you can directly assign an integer value to Timer.Interval. For example:

procedure TForm1.Button1Click(Sender: TObject);
var
  Interv: integer;
begin
  Interv := 2000;
  Timer1.Interval := Interv;
end;

In the code above, the integer variable Interv can be anything that results in an integer value, for example:

procedure TForm1.Button1Click(Sender: TObject);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
  Timer1.Interval := Ini.ReadInteger('Sect1', 'V1', 1000);
  Ini.Free;
end;


Related Articles and Replies