Recent

Author Topic: can not find TDictionary  (Read 7447 times)

isml

  • New Member
  • *
  • Posts: 15
can not find TDictionary
« on: April 14, 2018, 04:47:08 am »
Hi, everyone. I search the internet and find in Delphi I can "use System.Generics.Collections", but in lazarus I can not find this unit.How could I use TDictionary?

balazsszekely

  • Guest
Re: can not find TDictionary
« Reply #1 on: April 14, 2018, 06:04:35 am »
You need a newer version of FPC. AFAIK Generics.Collections is part of FPC trunk for almost two years now. The TDictionary from Generics.Collections is compatible with the one from Delphi System.Generics.Collections. For older versions of FPC,  the closest to TDictionary is TFPGMap from unit fgl. You can give it a try.

Thaddy

  • Hero Member
  • *****
  • Posts: 14393
  • Sensorship about opinions does not belong here.
Re: can not find TDictionary
« Reply #2 on: April 14, 2018, 07:58:45 am »
« Last Edit: April 14, 2018, 09:36:07 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

isml

  • New Member
  • *
  • Posts: 15
Re: can not find TDictionary
« Reply #3 on: April 14, 2018, 09:36:18 am »
I am using lazarus 1.8.2, the newest edition. But when I "use Generics.Collections", there are compile error. What package should I add?

isml

  • New Member
  • *
  • Posts: 15
Re: can not find TDictionary
« Reply #4 on: April 14, 2018, 09:37:52 am »
There is a version of generics.collections available that works with 3.0.4.
https://github.com/maciej-izak/generics.collections
(as per http://forum.lazarus.freepascal.org/index.php/topic,40404.msg279118.html#msg279118 )

Is there a built-in library? If not, I would try this.

balazsszekely

  • Guest
Re: can not find TDictionary
« Reply #5 on: April 14, 2018, 09:59:41 am »
@isml
You're mixing Lazarus with FPC. Lazarus 1.8.2 comes with FPC 3.0.4 and generics.collection is not included by default, so you have two solution:
1. Use a newer version of FPC, you can install a separate instance of Lazarus/FPC with fpcupdeluxe.exe(http://forum.lazarus.freepascal.org/index.php/topic,34645.0.html). It won't interfere with your current installation.
2. Install the package mentioned by @Thaddy

isml

  • New Member
  • *
  • Posts: 15
Re: can not find TDictionary
« Reply #6 on: April 14, 2018, 10:11:53 am »
Now I know where the problem is. Thanks for all the reply.

Thaddy

  • Hero Member
  • *****
  • Posts: 14393
  • Sensorship about opinions does not belong here.
Re: can not find TDictionary
« Reply #7 on: April 14, 2018, 10:24:54 am »
@isml
You're mixing Lazarus with FPC. Lazarus 1.8.2 comes with FPC 3.0.4 and generics.collection is not included by default, so you have two solution:
1. Use a newer version of FPC, you can install a separate instance of Lazarus/FPC with fpcupdeluxe.exe(http://forum.lazarus.freepascal.org/index.php/topic,34645.0.html). It won't interfere with your current installation.
2. Install the package mentioned by @Thaddy
2 .Which I can highly recommend if you are coming from Delphi and don't want a double installation. 3.0.4 is stable.
Just download from github and unpack in a directory. No further installation is needed. Just make sure it is in the path.
« Last Edit: April 14, 2018, 10:30:04 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018