Recent

Author Topic: Getting Compiler error and can't see why. Help Please  (Read 946 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Getting Compiler error and can't see why. Help Please
« on: May 26, 2020, 02:48:05 am »
I can't see why I'm getting this error.
unit1.pas(40,14) Error: Identifier not found "ThisType"


Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5.    Buttons, Classes, Clipbrd, Controls, Crt, DateUtils, Dialogs,
  6.    ExtCtrls, Forms, fphttpclient, fpjson, Graphics, jsonparser,
  7.    opensslsockets, StdCtrls, StrUtils, SysUtils, FileUtil, Unit2, SpinEx;
  8. type
  9.  
  10.   RType       = (AIATA, AICAO, FltData, TZone, FltNbr, Departure, Arrival, Airline, Flight, Aircraft, Codeshared, ATimeS, ATIMEE, NNBR, ANIL, xSTOP, live);
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15. {WIP - GetTypes}
  16.     function ThisType(AStub : String) : Rtype;
  17.   private
  18.   public
  19.   end;
  20.  
  21. var
  22.   Form1     : TForm1;
  23.   GRETURN   : AnsiString = '';
  24.  
  25. implementation
  26. {$R *.lfm}
  27. { TForm1 }
  28.  procedure GenericParserOfGRETURN(APROV : String; ABOX : TListbox);
  29.   var
  30.    AString : AnsiString = '';
  31.    Stub    : String = '';
  32.    Done    : Boolean = False;
  33.    AType   : Rtype;
  34.   begin
  35.     AString  := Trim(GRETURN);
  36.     Repeat
  37.     Stub := Copy2SymbDel(GRETURN, ',');
  38.     Stub := Trim(Stub);
  39.  
  40.     AType := ThisType(Stub);                          <------ ERROR
  41.  
  42.     Done := True;
  43.    Until Done;
  44.  end;
  45.  
  46.  function TForm1.ThisType(AStub : String) : Rtype;
  47.   Var
  48.    AType   : Rtype;
  49.    AString : String = '';
  50.   Begin
  51.    Result := AIATA;
  52.   end;
  53. end.
  54.  
« Last Edit: May 26, 2020, 02:50:46 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Getting Compiler error and can't see why. Help Please
« Reply #1 on: May 26, 2020, 03:02:19 am »
Hi!

procedure GenericParserOfGRETURN is  not part of the class TForm1.

Bad design workaround:

Code: Pascal  [Select][+][-]
  1. AType := Form1.ThisType(Stub);

Winni

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Getting Compiler error and can't see why. Help Please
« Reply #2 on: May 26, 2020, 03:09:45 am »
@Winni

I don't understand that. It's declared:

function TForm1.ThisType(AStub : String) : Rtype;

However, I noticed that GenericParserOfGRETURN isn't declared with "TForm1".

procedure GenericParserOfGRETURN(APROV : String; ABOX : TListbox);

It was because
procedure GenericParserOfGRETURN(APROV : String; ABOX : TListbox);
wasn't 
procedure TForm1.GenericParserOfGRETURN(APROV : String; ABOX : TListbox);

Thanks.

« Last Edit: May 26, 2020, 03:19:07 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

ccrause

  • Hero Member
  • *****
  • Posts: 856
Re: Getting Compiler error and can't see why. Help Please
« Reply #3 on: May 26, 2020, 08:50:01 am »
@Winni

I don't understand that. It's declared:

function TForm1.ThisType(AStub : String) : Rtype;

However, I noticed that GenericParserOfGRETURN isn't declared with "TForm1".

procedure GenericParserOfGRETURN(APROV : String; ABOX : TListbox);

It was because
procedure GenericParserOfGRETURN(APROV : String; ABOX : TListbox);
wasn't 
procedure TForm1.GenericParserOfGRETURN(APROV : String; ABOX : TListbox);

Thanks.

That is exactly what winni implied, just using different words...

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Getting Compiler error and can't see why. Help Please
« Reply #4 on: May 26, 2020, 07:54:47 pm »
Thank You
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018