* * *

Author Topic: Calling from procedure  (Read 517 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

  • Sr. Member
  • ****
  • Posts: 370
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;



Lazarus 1.3
FPC 2.7.1
Windows 7/8 32/64, OSX, *nix

Cranky

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

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus