Recent

Author Topic: What is an "identifier" and how is it used?  (Read 1519 times)

CarmichaelJohn

  • New Member
  • *
  • Posts: 46
What is an "identifier" and how is it used?
« on: September 19, 2020, 05:31:25 am »
Hello,
I am still having difficult porting over a program from Delphi.  The error of the day is one I do not understand at all.  I am using a Unit to provide the value of several constants to selected modules in my program.  The error happens right at the “const” word.  The error says: “Syntax error, “identifier” expected but “CONST” found.  This code worked in Delphi.  I tried researching identifiers but the writeups do not make sense to me.  What sort of identifier can I insert before “const” that is reasonable. All of the writeups refer to using a procedure, but that does not make sense to me.  Here is a few lines of the code:

Code: Pascal  [Select][+][-]
  1. unit UnitDataHolderConstants;
  2. {$mode objfpc}{$H+}
  3. interface
  4. Var
  5. //
  6. const
  7. Sqrt2Pi   = 2.506628275;
  8. TwoOVSqrtPi = 1.128379167;
  9. PiOver2   = 1.570796327;
  10. Sqrt2OVPi = 0.797884561;
  11. sinxEq05  = 0.050020856;  
  12. sinxEq95  = 1.520775471;  
  13. Euler     = 0.577215665;
  14. EulerMan  = 0.57721566490153286060651209008240243104215933593992;
  15. Napieron  = 2.71828183;
  16. //
  17. implementation
  18. end.

Any suggestions will be greatly appreciated,
John
 
(EDITED to add code tags: please see How to use the Forum)
« Last Edit: September 19, 2020, 07:47:58 am by trev »

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: What is an "identifier" and how is it used?
« Reply #1 on: September 19, 2020, 05:50:12 am »
The problem is that "Var" is not followed by a variable declaration.  The compiler complains about an identifier missing when it finds "const" because what it expected is a variable name (the variable name is what the compiler refers to as an "identifier".

Simply declare a variable after var, something like, "MyVariable : integer;" and that will correct the problem.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

CarmichaelJohn

  • New Member
  • *
  • Posts: 46
Re: What is an "identifier" and how is it used?
« Reply #2 on: September 19, 2020, 07:31:33 am »
440bx,
Thank you so much,  I just did not see it.
John

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: What is an "identifier" and how is it used?
« Reply #3 on: September 19, 2020, 08:57:08 am »
440bx,
Thank you so much,  I just did not see it.
John
You're welcome.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018