Recent

Author Topic: Error Message(Solved)  (Read 173 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1167
Error Message(Solved)
« on: August 12, 2022, 07:19:46 am »
I'm getting this error on line 22. unit1.pas(931,17) Error: method identifier expected

The error usually means a missing end statement above the line marked.
I don't see it. I have rewritten the function SizeLine 3 or 4 times. Now I'm not sure it makes sense. But until I get rid of the 'method identifier expected ' I won't know.

Code: Pascal  [Select][+][-]
  1. function TForm1.SizeLine(ALine: String): Integer;
  2.  Var i: Integer=1;
  3.   Cut: Integer=0;
  4.   Lgth: Integer;
  5.   Bit: String[1];
  6.  begin
  7.   Lgth:=Length(ALine);
  8.   if (Lgth = 0) Or (Lgth < 94) then begin Result:=Lgth+1; exit; end;
  9.  
  10.   for i := 1 to Lgth do begin
  11.       Bit:=ALine[i];
  12.       if (Bit= ' ') then begin
  13.           if (i < 94) then begin Cut:=i; end;
  14.       end;
  15.       if (Bit=' ') And (i=94) Or (i>94) then begin
  16.          Break;
  17.       end;
  18.   end;
  19.    Result:=Cut;
  20. end;
  21.  
  22. function TForm1.GetLinePrefix(AType: String): Integer;  <<< ERROR  HERE
  23.  Var LP: Integer;
  24.  begin
  25.   LP:=4;
  26.   Case AType of
  27.    'See Also': LP:=2;
  28.       'Notes': LP:=2;
  29.    'Augments': LP:=4;
  30.   end;
  31.    Result:=LP;
  32.   end;                    

GetLinePrefix was renamed to GetIndent in the declaration and call statement but not the function TForm1.GetLinePrefix(AType: String): Integer;
« Last Edit: August 12, 2022, 07:36:44 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

Josh

  • Hero Member
  • *****
  • Posts: 993
Re: Error Message - Don't Understand(
« Reply #1 on: August 12, 2022, 07:35:16 am »
Have you declared the procedure/function in your form class  see line 16,17
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     function SizeLine(ALine: String): Integer;
  17.     function GetLinePrefix(AType: String): Integer;
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31. { TForm1 }
  32.  
  33. function TForm1.SizeLine(ALine: String): Integer;
  34.  Var i: Integer=1;
  35.   Cut: Integer=0;
  36.   Lgth: Integer;
  37.   Bit: String[1];
  38.  begin
  39.   Lgth:=Length(ALine);
  40.   if (Lgth = 0) Or (Lgth < 94) then begin Result:=Lgth+1; exit; end;
  41.  
  42.   for i := 1 to Lgth do begin
  43.       Bit:=ALine[i];
  44.       if (Bit= ' ') then begin
  45.           if (i < 94) then begin Cut:=i; end;
  46.       end;
  47.       if (Bit=' ') And (i=94) Or (i>94) then begin
  48.          Break;
  49.       end;
  50.   end;
  51.    Result:=Cut;
  52. end;
  53.  
  54. function TForm1.GetLinePrefix(AType: String): Integer;  //<<< ERROR  HERE
  55.  Var LP: Integer;
  56.  begin
  57.   LP:=4;
  58.   Case AType of
  59.    'See Also': LP:=2;
  60.       'Notes': LP:=2;
  61.    'Augments': LP:=4;
  62.   end;
  63.    Result:=LP;
  64.   end;
  65.  
  66.  
  67. end.
  68.  

« Last Edit: August 12, 2022, 07:40:06 am by Josh »
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

JLWest

  • Hero Member
  • *****
  • Posts: 1167
Re: Error Message(Solved)
« Reply #2 on: August 12, 2022, 09:59:51 am »
@Josh

 Thanks The procedure wasn't declared.
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