Recent

Author Topic: [SOLVED] CLI Error Handling  (Read 4071 times)

RegNatarajan

  • New Member
  • *
  • Posts: 28
[SOLVED] CLI Error Handling
« on: April 25, 2014, 06:49:27 am »
Hello, I'm new both to Free Pascal and to this forum but I used Delphi for a lot of years in the past.  I'm trying to do a CLI program using FPC on CentOS Linux and it's throwing an error whenever I try to do basic error handling with try/except.  Is there something I need to put in my uses clause?  Or is this harder to solve than that?
« Last Edit: April 29, 2014, 09:10:08 am by RegNatarajan »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: CLI Error Handling
« Reply #1 on: April 25, 2014, 12:06:43 pm »
Quote
... and it's throwing an error ...
What error?

Laksen

  • Hero Member
  • *****
  • Posts: 745
    • J-Software
Re: CLI Error Handling
« Reply #2 on: April 25, 2014, 02:36:10 pm »
You should include Sysutils in your uses clause. It catches runtime errors and turns them into exceptions.

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: CLI Error Handling
« Reply #3 on: April 25, 2014, 11:59:05 pm »
Sorry, I was light on detail.

Compiling toptalkers.pas
toptalkers.pas(20,2) Error: Identifier not found "try"


I had already included sysutils.  Any input would be appreciated.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: CLI Error Handling
« Reply #4 on: April 26, 2014, 05:12:50 am »
you are still light on details. try adding the following line on top of your unit {$mode objfpc} and try again.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: CLI Error Handling
« Reply #5 on: April 26, 2014, 05:17:40 am »
Worked perfectly.  Thanks very much.   By the way, what did I just do?  lol.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: CLI Error Handling
« Reply #6 on: April 26, 2014, 05:28:23 am »
fpc supports multiple pascal dialects http://www.freepascal.org/docs-html/user/userse33.html some of them a bit old and they do not support the newer syntax/constructs, by adding the {$MODE XXXXXXX}  you instruct fpc to use a mode that supports all the constructs.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: CLI Error Handling
« Reply #7 on: April 26, 2014, 05:37:22 am »
Ah, ok understood.  I'm still very new to FPC.  Thanks again.

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: CLI Error Handling
« Reply #8 on: April 29, 2014, 07:29:08 am »
Not sure if this matters at all but this can be marked as solved.   taazz's solution worked perfectly.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: CLI Error Handling
« Reply #9 on: April 29, 2014, 07:40:06 am »
there is no options you an check to marked as solved you just edit your first post that started this thread and add the word solved usually at the the start of the thread's title.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: [SOLVED] CLI Error Handling
« Reply #10 on: April 29, 2014, 09:10:25 am »
Got it.  Done.  Thanks.

 

TinyPortal © 2005-2018