Recent

Author Topic: Calling from procedure  (Read 2427 times)

Cranky

  • Newbie
  • Posts: 4
Calling from procedure
« on: April 29, 2017, 12:54:06 am »
Hello, please I need help.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Label1: TLabel;
  17.     Timer1: TTimer;  
  18.     etc...  
I need to access Timer1 from my procedure
Code: Pascal  [Select][+][-]
  1. procedure simMain;
  2.  begin
  3.    TTimer.Enabled:=true;
  4.  end;  
but I am getting error: unit1.pas(70,4) Error: Identifier not found "Timer1"

Thanks for all replies :)

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Calling from procedure
« Reply #1 on: April 29, 2017, 01:33:15 am »
Hi

You have named your 'TTimer'  Timer1 and it is  part of the Form1

To access the timer call it by it's name ie
Timer1.enabled:=false;

Your procedure does not look to be part of the form , so to call it in this procedure you will also have to tell it where the timer1 is ie
procedure dosomething;
begin
  Form1.Timer1.enabled:=false;
end;



The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Cranky

  • Newbie
  • Posts: 4
Re: Calling from procedure
« Reply #2 on: April 29, 2017, 08:28:55 am »
Great it works, thank you  :)

 

TinyPortal © 2005-2018