Sign in Join

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

Mailing lists / fpc-pascal / 2000-09

'try-except'-problem

13 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Dominik Schulz

Hi!

I'm new to Free Pascal an Object Pascal. So I tried the following
program:
-----------------------
program testtry;
{$mode objfpc}
{$I-} //I'm not really sure whether this switch is usefull here.
uses crt;
var a, b : word;
begin
  writeln('start');
  a :=  1;
  b :=  a - 1;
  try
    a := 1 div b;
  except
    writeln('Error');
  end;
  writeln('end');
end.
-----------------------

This program always crashes with RE 200.
Why doesn't the try-except-block avoid this?

Thank you in advance!

ciao, Dominik

Reply by email

Unknown author
to Dominik Schulz: Hi! I'm new to Free Pascal an Object Pascal. So I tried the following program:…
Dominik Schulz wrote 28 lines
Hi! I'm new to Free Pascal an Object Pascal. So I tried the following program: ----------------------- program testtry; {$mode objfpc} {$I-} //I'm not really sure whether this switch is usefull here. uses crt; var a, b : word; begin writeln('start'); a := 1; b := a - 1; try a := 1 div b; except writeln('Error'); end; writeln('end'); end. ----------------------- This program always crashes with RE 200. Why doesn't the try-except-block avoid this?

Because you must use sysutils; if you don't use sysutils, then the RTE is not converted to an exception, and so the try..except block is not useful.

so all you need to do is add 'sysutils' to the uses clause.

This is the same behaviour as Delphi, BTW.

Michael.

Reply by email

Dominik Schulz
to Unknown author
Show quoted text 5 lines
On Fri, 15 Sep 2000, Dominik Schulz wrote: > This program always crashes with RE 200. > Why doesn't the try-except-block avoid this? so all you need to do is add 'sysutils' to the uses clause.

Okay, did did so. After that the compiler complained about missing units ans include files. So I added the paths in the config file. Now the compiler stops with these messages:
----------------------------------------------------------------- base.inc(293,62) Note: Values in enumeration types have t base.inc(293,83) Note: Values in enumeration types have t base.inc(294,27) Note: Values in enumeration types have t base.inc(355,38) Error: Error in type definition
base.inc(363,38) Error: Error in type definition
base.inc(371,42) Error: Error in type definition
base.inc(418,48) Error: Error in type definition
base.inc(428,49) Error: Error in type definition
base.inc(432,49) Error: Error in type definition
base.inc(545,92) Error: Error in type definition
struct.inc(1384,49) Error: Error in type definition struct.inc(1385,71) Error: Error in type definition Compilation aborted struct.inc:1385
Runtime error 216 at 0x0048A612
0x0048A612
0x004950B1
0x004362F0
0x00431ADC
0x00431E48
0x00433D97
0x0043814A
0x00402FD6
0x00440741
0x00401CC3
-------------------------------------------------------------

What is still wrong?

BTW: I don't know, why my last E-Mail was send twice.

Dominik

Reply by email

Tobias Hermann
to Dominik Schulz: Hi! I'm new to Free Pascal an Object Pascal. So I tried the following program:…

haven't you to use something like this? :

try
  ..
except
  on Exception do
   writeln('Error');
end;

???

Tobi

Earlier message 45 lines
----- Original Message ----- From: Dominik Schulz To: Sent: Friday, September 15, 2000 10:39 PM Subject: [fpc-pascal]'try-except'-problem > Hi! > > I'm new to Free Pascal an Object Pascal. So I tried the following > program: > ----------------------- > program testtry; > {$mode objfpc} > {$I-} file://I'm not really sure whether this switch is usefull here. > uses crt; > > var a, b : word; > > begin > writeln('start'); > a := 1; > b := a - 1; > try > a := 1 div b; > except > writeln('Error'); > end; > > writeln('end'); > end. > ----------------------- > > This program always crashes with RE 200. > Why doesn't the try-except-block avoid this? > > Thank you in advance! > > ciao, Dominik > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Unknown author
to Dominik Schulz: Okay, did did so. After that the compiler complained about missing units ans include…
Dominik Schulz wrote 10 lines
wrote: > On Fri, 15 Sep 2000, Dominik Schulz wrote: > > This program always crashes with RE 200. > > Why doesn't the try-except-block avoid this? > > so all you need to do is add 'sysutils' to the uses clause. Okay, did did so. After that the compiler complained about missing units ans include files. So I added the paths in the config file.

This is not normal. It should compile just like that, without recompiling the syslinux unit. Can you send the output of a compile with -va and the paths NOT in the config file ?

and do NOT compile when in the rtl/win32 directory.

Michael.

Reply by email

Dominik Schulz
to Unknown author
Show quoted text 8 lines
> wrote: > > On Fri, 15 Sep 2000, Dominik Schulz wrote: > > > This program always crashes with RE 200. > > > Why doesn't the try-except-block avoid this? > > This is not normal. It should compile just like that, without recompiling the syslinux unit. Can you send the output of a compile with -va and the paths NOT in the config file ?

I loaded up two file that contain the output. This one is for compilation with the win32 target:
http://home.c-nit.de/hjschulz/misc/log

And this one with the go32v2 target:
http://home.c-nit.de/hjschulz/misc/log2
Using -Tgo32v2 the compiler does'nt crash, but the RE 200 still occurs after running the program.

Paths:
The unit strings was missing. I found it in this directory, although it is for include files (or am I wrong?). I copied it into a unit directory: \source\rtl\inc

I added this path too:
\source\rtl\objpas

Dominik

Reply by email

Dominik Schulz
to Tobias Hermann: haven't you to use something like this? : try .. except on Exception do writeln('Error');…
"Tobias Hermann" wrote 8 lines
haven't you to use something like this? : try .. except on Exception do writeln('Error'); end;

I tried it, but still got RE 200.

-------------------------------------------------
program testtry;
{$mode delphi}
uses crt, sysutils;
var a, b : word;
begin
  writeln('start');
  a :=  1;
  b :=  a - 1;
  try
    a := 1 div b;
  except
    on exception do writeln('error');
  end;
  writeln('end');
end.
-------------------------------------------------

Removing ', sysutils' the compiler puts out this:
-------------------------------------------------
Compiling testtry.pas
testtry.pas(16,18) Error: Identifier not found EXCEPTION testtry.pas(16,18) Error: class type expected, but got "<erroneous type>" testtry.pas(22) Fatal: There were 2 errors compiling module, stopping -------------------------------------------------

I do not know any class, which I could use here.

Dominik

Reply by email

Unknown author
to Dominik Schulz: I loaded up two file that contain the output. This one is for compilation with the win32…
Dominik Schulz wrote 13 lines
wrote: > > wrote: > > > On Fri, 15 Sep 2000, Dominik Schulz wrote: > > > > This program always crashes with RE 200. > > > > Why doesn't the try-except-block avoid this? > > > > This is not normal. It should compile just like that, without recompiling > the syslinux unit. Can you send the output of a compile with -va and the > paths NOT in the config file ? I loaded up two file that contain the output. This one is for compilation with the win32 target: http://home.c-nit.de/hjschulz/misc/log

But you must _remove_ all the paths which you have in the unit path. it should be a clean compile, i.e. no RTL files should be found.

So, please: try the following command:

ppc386 -n -va -S2 yourfile.pp
(the -n makes sure no config file is read).

collect the output of that command.

Michael.

Reply by email

Dominik Schulz
to Unknown author
So, please: try the following command: ppc386 -n -va -S2 yourfile.pp

--------------------------------------------------------- Compiler: c:\dokumente\daten\fpc\bin\win32\ppc386.exe Compiler OS: Win32 for i386
Target OS: Win32 for i386
Using executable path: c:\dokumente\daten\fpc\bin\win32\ Using unit path: .\bin\win32\
Using library path: .\bin\win32\
Using object path: .\bin\win32\
Compiling testtry.pas
Macro defined: WIN32
Macro defined: FPC
Macro defined: VER1
Macro defined: VER1_1
Macro defined: VER1_1_0
Macro defined: HASWIDECHAR
Macro defined: PACKENUMFIXED
Macro defined: HASOUT
Macro defined: CPU86
Macro defined: CPU87
Macro defined: CPUI386
Macro defined: FPC_LINK_SMART
Macro FPC_VERSION set to 1
Macro FPC_RELEASE set to 1
Macro FPC_PATCH set to 0
194 Kb Free
testtry.pas(4,1) Macro defined: FPC_DELPHI
Load from TESTTRY (implementation) unit SYSWIN32
Unitsearch: syswin32.ppw
Unitsearch: syswin32.pp
Unitsearch: syswin32.pas
Unitsearch: .\bin\win32\syswin32.ppw
Unitsearch: .\bin\win32\syswin32.pp
Unitsearch: .\bin\win32\syswin32.pas
Fatal: Can't find unit SYSWIN32
---------------------------------------------------------

(Unit syswin32.pp|ppw is in source\rtl\win32.)

Dominik

Reply by email

Unknown author
to Dominik Schulz
Dominik Schulz wrote 43 lines
wrote: > So, please: try the following command: > ppc386 -n -va -S2 yourfile.pp > ppc386 -n -va -S2 yourfile.pp --------------------------------------------------------- Compiler: c:\dokumente\daten\fpc\bin\win32\ppc386.exe Compiler OS: Win32 for i386 Target OS: Win32 for i386 Using executable path: c:\dokumente\daten\fpc\bin\win32\ Using unit path: .\bin\win32\ Using library path: .\bin\win32\ Using object path: .\bin\win32\ Compiling testtry.pas Macro defined: WIN32 Macro defined: FPC Macro defined: VER1 Macro defined: VER1_1 Macro defined: VER1_1_0 Macro defined: HASWIDECHAR Macro defined: PACKENUMFIXED Macro defined: HASOUT Macro defined: CPU86 Macro defined: CPU87 Macro defined: CPUI386 Macro defined: FPC_LINK_SMART Macro FPC_VERSION set to 1 Macro FPC_RELEASE set to 1 Macro FPC_PATCH set to 0 194 Kb Free testtry.pas(4,1) Macro defined: FPC_DELPHI Load from TESTTRY (implementation) unit SYSWIN32 Unitsearch: syswin32.ppw Unitsearch: syswin32.pp Unitsearch: syswin32.pas Unitsearch: .\bin\win32\syswin32.ppw Unitsearch: .\bin\win32\syswin32.pp Unitsearch: .\bin\win32\syswin32.pas Fatal: Can't find unit SYSWIN32 --------------------------------------------------------- (Unit syswin32.pp|ppw is in source\rtl\win32.)

isn't there a unit in units\win32(\rtl) ?

There should be if you installed everything correctly ?

Michael.

Reply by email

Dominik Schulz
to Unknown author
Show quoted text 15 lines
On Sun, 17 Sep 2000, Dominik Schulz wrote: > wrote: > > So, please: try the following command: > > ppc386 -n -va -S2 yourfile.pp > --------------------------------------------------------- > Compiler: c:\dokumente\daten\fpc\bin\win32\ppc386.exe > [...] > Fatal: Can't find unit SYSWIN32 > --------------------------------------------------------- > > (Unit syswin32.pp|ppw is in source\rtl\win32.) isn't there a unit in units\win32(\rtl) ? There should be if you installed everything correctly ?

Yes sorry, I found it in units\win32\rtl too.

Dominik

Reply by email