Recent

Author Topic: [SOLVED] Type conversion?  (Read 2249 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Type conversion?
« Reply #15 on: August 16, 2022, 01:23:00 pm »
Thank you for your advices.  This compiles in {$mode objfpc}.
Haven't tested running yet. I'll post the result.

Please report this as a bug then.

As a workaround you can also use Val instead of ReadStr if the whole string only contains the enum value:

Code: Pascal  [Select][+][-]
  1. var
  2.   ts: String;
  3.   anIT: TInputTypes;
  4.   code: Integer;
  5. begin
  6.   ts := 'itText';
  7.   Val(ts, anIT, code);
  8.   if code <> 0 then
  9.     // there was an error
  10.   else
  11.     // ok
  12.     ;
  13. end.

egsuh

  • Hero Member
  • *****
  • Posts: 1289
Re: [SOLVED] Type conversion?
« Reply #16 on: August 17, 2022, 05:19:32 am »
Quote
Please report this as a bug then.

It compiles well in {$mode objfpc}. Do you mean to report a but, because it does not compile in {$mode delphi}?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: [SOLVED] Type conversion?
« Reply #17 on: August 17, 2022, 09:06:01 am »
Quote
Please report this as a bug then.

It compiles well in {$mode objfpc}. Do you mean to report a but, because it does not compile in {$mode delphi}?

Yes, because it should compile with a different $PackEnum setting as well (which is where mode ObjFPC differs from Delphi). After all the user might not be able to control where the enum comes from.

egsuh

  • Hero Member
  • *****
  • Posts: 1289
Re: [SOLVED] Type conversion?
« Reply #18 on: April 07, 2024, 04:27:17 am »
I have reported this issue to bug tracker, which does not seem fixed, in Lazarus 3.2.

 

TinyPortal © 2005-2018