Recent

Author Topic: Error: Identifier not found.  (Read 2671 times)

AfootDesert41

  • New Member
  • *
  • Posts: 15
Error: Identifier not found.
« on: December 29, 2018, 11:15:21 pm »
I want to make a usuariocajerobarra Tedit only readable and to store the usuariocajerobarra Tedit input to the usuariocajero_ing global variable, but, I'm getting identifier not found error for both the Tedit form and the variable even thought I have added Unit 3 to Unit 1 uses and declared global variables. What's wrong?

Here is the code for unit 1:

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, StdCtrls,
  9.   Grids,Unit2,Unit3,Unit4,Unit5;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     botonborrarcliente: TButton;
  17.     botonagregarcliente: TButton;
  18.     Button1: TButton;
  19.     Button2: TButton;
  20.     botonborrarproductomain: TButton;
  21.     botonagregarproductomain: TButton;
  22.     botonfacturar: TButton;
  23.     subtotalbarra: TEdit;
  24.     ivabarra: TEdit;
  25.     totalbarra: TEdit;
  26.     GroupBox3: TGroupBox;
  27.     Label6: TLabel;
  28.     Label7: TLabel;
  29.     Label8: TLabel;
  30.     StringGrid1: TStringGrid;
  31.     usuariocajerobarra: TEdit;
  32.     GroupBox2: TGroupBox;
  33.     Label5: TLabel;
  34.     nombrerazonsocialbarra: TEdit;
  35.     apellidobarra: TEdit;
  36.     cedularifbarra: TEdit;
  37.     direccionbarra: TEdit;
  38.     GroupBox1: TGroupBox;
  39.     Label1: TLabel;
  40.     Label2: TLabel;
  41.     Label3: TLabel;
  42.     Label4: TLabel;
  43.     procedure botonagregarclienteClick(Sender: TObject);
  44.     procedure botonagregarproductomainClick(Sender: TObject);
  45.     procedure botonborrarclienteClick(Sender: TObject);
  46.     procedure botonfacturarClick(Sender: TObject);
  47.     procedure Button1Click(Sender: TObject);
  48.     procedure Button2Click(Sender: TObject);
  49.   private
  50.  
  51.   public
  52.   nombreorazonsocial_ing,apellido_ing,cedulaorif_ing,direccion_ing,
  53.   usuariocajero_ing:String;
  54.   end;
  55.  
  56. var
  57.   Form1: TForm1;
  58.  
  59. implementation
  60.  
  61. {$R *.lfm}
  62.  
  63. { TForm1 }
  64.  
  65. procedure TForm1.botonagregarproductomainClick(Sender: TObject);
  66. begin
  67.   form2.showmodal;
  68. end;
  69.  
  70. procedure TForm1.botonborrarclienteClick(Sender: TObject);
  71. begin
  72.   nombreorazonsocial_ing:=#0;
  73.   nombrerazonsocialbarra.ReadOnly:=False;
  74.   nombrerazonsocialbarra.Text:='';
  75.   apellido_ing:=#0;
  76.   apellidobarra.ReadOnly:=False;
  77.   apellidobarra.Text:='';
  78.   cedulaorif_ing:=#0;
  79.   cedularifbarra.ReadOnly:=False;
  80.   cedularifbarra.Text:='';
  81.   direccion_ing:=#0;
  82.   direccionbarra.ReadOnly:=False;
  83.   direccionbarra.Text:='';
  84. end;
  85.  
  86. procedure TForm1.botonagregarclienteClick(Sender: TObject);
  87. begin
  88.   nombreorazonsocial_ing:=nombrerazonsocialbarra.text;
  89.   nombrerazonsocialbarra.ReadOnly:=True;
  90.   apellido_ing:=apellidobarra.Text;
  91.   apellidobarra.ReadOnly:=True;
  92.   cedulaorif_ing:=cedularifbarra.Text;
  93.   cedularifbarra.ReadOnly:=True;
  94.   direccion_ing:=direccionbarra.Text;
  95.   direccionbarra.readonly:=True;
  96. end;
  97.  
  98. procedure TForm1.botonfacturarClick(Sender: TObject);
  99. begin
  100.   form4.showmodal;
  101. end;
  102.  
  103. procedure TForm1.Button1Click(Sender: TObject);
  104. begin
  105.   form3.showmodal;
  106. end;
  107.  
  108. procedure TForm1.Button2Click(Sender: TObject);
  109. begin
  110.   usuariocajero_ing:=#0;
  111.   usuariocajerobarra.text:='';
  112. end;
  113.  
  114. end.
  115.  

Unit 3 code:

Code: Pascal  [Select][+][-]
  1. unit Unit3;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm3 }
  13.  
  14.   TForm3 = class(TForm)
  15.     botoniniciarsesionunit3: TButton;
  16.     botoncancelarunit3: TButton;
  17.     usuariocajerobarraunit3: TEdit;
  18.     GroupBox1: TGroupBox;
  19.     Label1: TLabel;
  20.     procedure botoncancelarunit3Click(Sender: TObject);
  21.     procedure botoniniciarsesionunit3Click(Sender: TObject);
  22.   private
  23.  
  24.   public
  25.  
  26.   end;
  27.  
  28. var
  29.   Form3: TForm3;
  30.  
  31. implementation
  32.  
  33. {$R *.lfm}
  34.  
  35. { TForm3 }
  36.  
  37. procedure TForm3.botoniniciarsesionunit3Click(Sender: TObject);
  38. begin
  39.   usuariocajero_ing:=usuariocajerobarraunit3.Text;
  40.   usuariocajerobarra.ReadOnly:=True;
  41.   form3.close;
  42. end;
  43.  
  44. procedure TForm3.botoncancelarunit3Click(Sender: TObject);
  45. begin
  46.   form3.close;
  47. end;
  48.  
  49. end.
  50.  

rvk

  • Hero Member
  • *****
  • Posts: 6758
Re: Error: Identifier not found.
« Reply #1 on: December 29, 2018, 11:36:57 pm »
What's the exact error message and on what line?

Don't let us guess.

AfootDesert41

  • New Member
  • *
  • Posts: 15
Re: Error: Identifier not found.
« Reply #2 on: December 29, 2018, 11:54:17 pm »
Thanks for answering, this is what I get on messages window:

Compile Project, Target: project1.exe: Exit code 1, Errors: 2
unit3.pas(39,3) Error: Identifier not found "usuariocajero_ing"
unit3.pas(40,3) Error: Identifier not found "usuariocajerobarra"

jamie

  • Hero Member
  • *****
  • Posts: 6953
Re: Error: Identifier not found.
« Reply #3 on: December 30, 2018, 12:00:45 am »
you can not do it that way..

in unit3 it needs to know of UNIT1,  however, if you try to add that to the USES list of unit3 it will complain about
a recirculating reference..

 You can add that in the USES in the Implementation section.

Implementation

Uses UNIT1;


and to gain access to the properties of UNIT1 you do this.

Form1.us...._ing;
-----

A better way to do this is to make a property in FORM3 that can be read back..

FORM3.ReturningValue:String;

Somewhere in the FORM3 code you do this..

ReturningValue := ????

Hope that helps
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018