Recent

Author Topic: [SOLVED] Compile time error for function declaration, why?  (Read 3781 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
[SOLVED] Compile time error for function declaration, why?
« on: June 29, 2012, 10:19:48 pm »
Hi everyone,

I have put a function in an application, to convert a fieldtype value to a string, that I found on the web.

function FldToStr(const Value : TFieldType) : String;
begin
   Case Value of
   ftUnknown    :  FldToStr := 'Unknown';
      (etc.)
      (etc.)
   ftTimeStamp   :  FldToStr := 'TimeStamp';
   ftFMTBcd   :  FldToStr := 'FMTBcd';
   end;
end;


I get this error:
unit1.pas(51,1) Fatal: Syntax error, "identifier" expected but "BEGIN" found

The error detector  highlites the code-line with the word 'begin'.

Would appreciate help on getting it right.

Thanks!


« Last Edit: June 30, 2012, 09:50:43 am by Elmug »

Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: Compile time error for function declaration, why?
« Reply #1 on: June 30, 2012, 12:23:16 am »
Did you put it in the interface section?

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Compile time error for function declaration, why?
« Reply #2 on: June 30, 2012, 07:57:21 am »
Did you put it in the interface section?

Thanks, Laksen for pointing this out.

I went back to a working backup, and carefully pasted it on it, and at the implementation section, and it has now compiled without errors. I can't really say now what specifically was wrong, as I tried on the current version to resolve it and gave up. But it definitely was a typo of some sort, or a deleted line somewhere.

I am moving on to using it and see if I can get this resolved.

Will report back, if I can do it, or if I get stuck.

EDITED TO  REPORT BACK: Got it all squared out. Reference:
   http://www.lazarus.freepascal.org/index.php/topic,17406.0.html
« Last Edit: June 30, 2012, 09:50:15 am by Elmug »