Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-02

Error: Identifier not found "try"

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

T.Guilleminot

Hello,

The simple program below fails when compiling (2.2.2-8 and 2.2.4rc1) :

program TEST_TRY;
uses SysUtils, strutils;
Function IsNumber(ValueToCheck:string):boolean;
begin
  try
    StrToInt(ValueToCheck);
    IsNumber := true;
  except
    IsNumber := false;
  end;
end;
begin
  If IsNumber('123') then
    writeln('this is a number');
end.

fpc Test_Try.pas
Free Pascal Compiler version 2.2.4rc1 [2009/01/25] for i386 Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling Test_Try.pas
Test_Try.pas(8,4) Error: Identifier not found "try" Test_Try.pas(8,4) Fatal: Syntax error, ";" expected but "identifier STRTOINT" found
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

Did I miss something obvious ?
Thanks

Reply by email

Jonas Maebe
to T.Guilleminot
T.Guilleminot wrote 13 lines
fpc Test_Try.pas Free Pascal Compiler version 2.2.4rc1 [2009/01/25] for i386 Copyright (c) 1993-2008 by Florian Klaempfl Target OS: Linux for i386 Compiling Test_Try.pas Test_Try.pas(8,4) Error: Identifier not found "try" Test_Try.pas(8,4) Fatal: Syntax error, ";" expected but "identifier STRTOINT" found Fatal: Compilation aborted Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) Did I miss something obvious ?

Yes, you have to activate the Delphi or ObjFPC compilation mode. You may want to read http://wiki.lazarus.freepascal.org/Code_Conversion_Guide if you are coming from Delphi or Kylix (e.g., this issue is mentioned here: http://wiki.lazarus.freepascal.org/Code_Conversion_Guide#Selecting_the_right_compiler_mode )

Jonas

Reply by email