Recent

Author Topic: try/except error  (Read 349 times)

toby

  • Sr. Member
  • ****
  • Posts: 283
try/except error
« on: July 15, 2026, 08:47:41 pm »

i am working on some different pascal coding for sftp (i would like a cli sftp like the c one that comes in

i am having trouble seeing the error in a try/except code
i am on linux with fpc-3.3.1
i downloaded https://www.syncovery.com/release/tgputtylib-build30.zip

unzipped it to tgputty.release dir

cd tgputty.release/FPCSimpleDemos

fpc fpcsftpclasstest.lpr

with output
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Target OS: Linux for x86-64
Compiling fpcsftpclasstest.lpr
fpcsftpclasstest.lpr(3,2) Warning: APPTYPE is not supported by the target OS      i commented this line with no effect
Compiling ../tgputtylib.pas
tgputtylib.pas(500,12) Hint: Conversion between ordinals and pointers is not portable
tgputtylib.pas(591,5) Error: Illegal expression
tgputtylib.pas(592,7) Fatal: Syntax error, ";" expected but "identifier ON" found
Fatal: Compilation aborted

../tgputtylib.pas
          TGPuttyLibLoadError:='dlopen failed, errno='+IntToStr(errno);
       end;
    {$endif}
    except            <- line 591
      on E:Exception do begin
         Result:=false;
         TGPuttyLibLoadError:=E.Message;
         end;
    end;
  end;


bytebites

  • Hero Member
  • *****
  • Posts: 794
Re: try/except error
« Reply #1 on: July 15, 2026, 09:34:50 pm »
Missing try statement

toby

  • Sr. Member
  • ****
  • Posts: 283
Re: try/except error
« Reply #2 on: July 15, 2026, 09:47:24 pm »
i think it is on line 487   isn't it?

H₂SO₄

  • Sr. Member
  • ****
  • Posts: 485
Re: try/except error
« Reply #3 on: July 16, 2026, 07:05:35 am »
Whoever wrote this code obviously never tested it for any platform other than Windows (it won't compile anywhere else):

Code: Pascal  [Select][+][-]
  1. {$ifdef MSWINDOWS}
  2. Result:=true;
  3. try
  4.   CheckStructSizes;
  5.   {$else}
  6.   // Unix-specifc code (uses `dlopen`)
  7. {$endif}
  8. except
  9.   on E:Exception do begin
  10.      Result:=false;
  11.      TGPuttyLibLoadError:=E.Message;
  12.      end;
  13. end;

Adding/removing an  {$ifdef}  would fix this, but I can't even decipher what the original intention was. Should the non-windows code also run under the  try..except  block? Should  CheckStructSizes  also be called on other platforms?

Thaddy

  • Hero Member
  • *****
  • Posts: 19625
  • Glad to be alive.
Re: try/except error
« Reply #4 on: July 16, 2026, 07:23:48 am »
The download contains a lot of compiled binaries so I deleted it. Highly unprofessional distribution.
Any "programmer" that knows only one programming language is not a programmer

toby

  • Sr. Member
  • ****
  • Posts: 283
Re: try/except error
« Reply #5 on: July 16, 2026, 06:55:42 pm »
Khrys

thank you for your replay

your contention that :

Whoever wrote this code obviously never tested it for any platform other than Windows (it won't compile anywhere else):

and having a .lpr fpc program extemsion in a FPCSimpleDemos directory ....

commenting that {$ifdef MSWINDOWS}  the {$else} and the  {$endif}  got it to compile on linux using fpc

and when run got
TGPuttyLib not available: TGPuttyLib loading problem - most likely the DLL is missing or a 32 versus 64 bit mismatch!

i'll compile the .so and see how far i get

---

thaddy

at least we know you know how to use unzip

i'm sure there are no precompiled binaries on your system from your linux distribution :)

---

 

TinyPortal © 2005-2018