Forum > General

Generics.Collections

(1/3) > >>

Vaytl:
Hi.
I am trying to migrate a project from Delphi to Lazarus.
I came across a generic, and I can't understand how it works at all. Is there some way to replace this code to opt out of "Generics.Collections"?

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---private class var Dictionary: TDictionary<DWORD_PTR, Boolean>;....................if not TMyprogramm.Dictionary.TryGetValue(Context, LBool)  then exit;....................Dictionary.TryAdd(DWORD_PTR(fContext), True);....................      initialization  TMyprogramm.Dictionary := TDictionary<DWORD_PTR, Boolean>.create; 

marcov:
It should work, but DWORD_PTR is a Windows specific type.

Are you compiling on Windows, and what is your exact errormessage?

Vaytl:

--- Quote from: marcov on January 10, 2022, 10:53:53 pm ---Are you compiling on Windows, and what is your exact errormessage?

--- End quote ---

Yes, I compiling on windows.
Error: identifier idents no member "tryAdd"

Remy Lebeau:

--- Quote from: Vaytl on January 10, 2022, 11:01:33 pm ---Error: identifier idents no member "tryAdd"

--- End quote ---

FPC's TDictionary does not have a TryAdd() method.  Delphi's TDictionary has had TryAdd() for only a few years (since 10.3 Rio), so likely hasn't made its way into FPC yet.

PascalDragon:

--- Quote from: Remy Lebeau on January 11, 2022, 01:09:07 am ---
--- Quote from: Vaytl on January 10, 2022, 11:01:33 pm ---Error: identifier idents no member "tryAdd"

--- End quote ---

FPC's TDictionary does not have a TryAdd() method.  Delphi's TDictionary has had TryAdd() for only a few years (since 10.3 Rio), so likely hasn't made its way into FPC yet.

--- End quote ---

Would someone please report a bug so that it's not forgotten?

Navigation

[0] Message Index

[#] Next page

Go to full version