Recent

Author Topic: ConvUtils unit misses some Delphi features  (Read 963 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
ConvUtils unit misses some Delphi features
« on: June 05, 2022, 09:30:20 pm »
Delphi unit docs:
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.ConvUtils

FPC unit misses:

CompatibleConversionType
CompatibleConversionTypes
ConvertTo
ConvUnitAdd
ConvUnitCompareValue
ConvUnitDec
ConvUnitDiff
ConvUnitInc
etc
« Last Edit: June 06, 2022, 11:55:17 am by AlexTP »

Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #1 on: June 05, 2022, 10:39:02 pm »
Feel free to supply patches for that functionality.

My favorite: TryStrToConvUnit, it should parse something like '3.5 pound'.
Not sure if it will return money or weight though.

Bart
« Last Edit: June 05, 2022, 10:41:49 pm by Bart »

Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #2 on: June 06, 2022, 06:38:24 pm »
Implemented:
  • More temperature conversions
  • ConvertTo
  • ConvUnitAdd
  • ConvUnitDiff
  • ConvUitInc
  • ConvUnitDec
  • ConvUnitSameValue
  • ConvUnitCompareValue

So maybe you (AlexTP) can implement CompatibleConversionType and CompatibleConversionTypes?

Bart

Bart

Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #3 on: June 06, 2022, 06:53:49 pm »
So maybe you (AlexTP) can implement CompatibleConversionType and CompatibleConversionTypes?

Never mind, did that as well.

Bart

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: ConvUtils unit misses some Delphi features
« Reply #4 on: June 06, 2022, 08:23:42 pm »
Great, thank you very much! I was busy today adding the new encoding to LConvEncoding.


Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #6 on: June 07, 2022, 12:08:09 pm »
I know.

Bart

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: ConvUtils unit misses some Delphi features
« Reply #7 on: June 11, 2022, 12:07:17 pm »
Bart, a small idea.
Since cIllegalXXXX are zeros, let's make 'fake' ConvType and 'fake' ConvFamily for zero, which is not converting anything.

Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #8 on: June 12, 2022, 10:26:55 am »
I opted for a different solution based upon the observed behaviour of Delpi that in fact raises an exception, even when the docs say it returns 0.
There's another problem with functions returning a string. The y cannot return an error value (currently they return some thing like '[$0000FFFF]' for e.g. a none existing TConvType. But since any string value (even en emty string) is a valid description for a TConvType (or a TConvFamily) there is no way to let such a function indicate there's an error.

For the implementation part I implemented some TryXXX functions that return False upon failure, much like the TryStrToInt() etc. functions.

Bart

Bart

  • Hero Member
  • *****
  • Posts: 4745
    • Bart en Mariska's Webstek
Re: ConvUtils unit misses some Delphi features
« Reply #9 on: June 12, 2022, 11:22:00 pm »
And some more: Issue 39778.

Bart

 

TinyPortal © 2005-2018