tlist

Delphi - Access violation while creating a TList of UnicodeString

会有一股神秘感。 提交于 2020-07-10 12:23:44
问题 I'm writing a Delphi package with RAD Studio XE7. I recently faced a strange access violation, and I cannot figure out why it happened. The context was that I was trying to maintain a list of font names. So I declared the following type: ICustomFontList = TList<UnicodeString>; Inside one of my classes, I declared a variable as follow: m_pCustomFontList: ICustomFontList; Then, in the constructor, I tried to instantiate this variable like that: m_pCustomFontList := ICustomFontList.Create; I

Delphi - Access violation while creating a TList of UnicodeString

旧巷老猫 提交于 2020-07-10 12:10:13
问题 I'm writing a Delphi package with RAD Studio XE7. I recently faced a strange access violation, and I cannot figure out why it happened. The context was that I was trying to maintain a list of font names. So I declared the following type: ICustomFontList = TList<UnicodeString>; Inside one of my classes, I declared a variable as follow: m_pCustomFontList: ICustomFontList; Then, in the constructor, I tried to instantiate this variable like that: m_pCustomFontList := ICustomFontList.Create; I

How to look into generic tList during Delphi debugging

北城余情 提交于 2020-03-16 05:54:06
问题 I use Delphi 10.3.1 COMMUNITY version and can't look into generic tList while I debug the project. I know the latest version of Delphi doesn't support the old-typed debug feature which allows to look into generic tList. So I used tList.List in the following code to evaluate the tList. In tList<tRecord>.List I can look into it but can't do it in tList<Integer>.List . type tRecord = record Field: Integer; end; procedure TForm1.FormCreate(Sender: TObject); var _Record: tRecord; _List1: TList

Delphi XE8 bug in TList<T>, need workaround

佐手、 提交于 2019-12-29 18:34:03
问题 After upgrading to XE8 some of our projects start to break data. Looks like a bug in TList realization. program XE8Bug1; {$APPTYPE CONSOLE} uses System.SysUtils, Generics.Collections; type TRecord = record A: Integer; B: Int64; end; var FRecord: TRecord; FList: TList<TRecord>; begin FList := TList<TRecord>.Create; FRecord.A := 1; FList.Insert(0, FRecord); FRecord.A := 3; FList.Insert(1, FRecord); FRecord.A := 2; FList.Insert(1, FRecord); Writeln(IntToStr(FList[0].A) + IntToStr(FList[1].A) +

How do I search a generic TList<T> collection? [duplicate]

谁说我不能喝 提交于 2019-12-21 09:18:25
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How can I search a generic TList for a record with a certain field value? I have a collection of TList<TActivityCategory> TActivityCategory has a Name property of type string and I want to search the TList using the Name property. I see BinarySearch in the TList<> but that would require an instance of TActivityCategory. I just want to pass the string for a name. How would I go about doing this? 回答1: When you

Pass array (or TList) from C# code behind to external javascript?

柔情痞子 提交于 2019-12-12 01:34:53
问题 I need to pass a list (or array) of IP addresses and other information from C# code behind to the javascript function, which is in the external .js.. Also, this list may be long (1000+ items) .. What is the most efficient way to do this? can you provide a small example? should I use json serialization? 回答1: var myObject = <%= JustSerializeAsJson(...) %>; ... or pass it to a function to whatever. Point is JSON is a valid JavaScript literal so you can drop it in a number of places. Don't worry

Delphi: Problems with TList of Frames

天涯浪子 提交于 2019-12-11 13:28:21
问题 I'm having a problem with an interface that consists of a number of frames (normally 25) within a TScrollBox. There are 2 problems, and I am hoping that one is a consequence of the other... Background: When the application starts up, I create 25 frames, each containing approx. 20 controls, which are then populated with the default information. The user can then click on a control to limit the search to a subset of information at which point I free and recreate my frames (as the search may

Delphi TList<T> Copy into another TList?

风流意气都作罢 提交于 2019-12-10 11:41:35
问题 I would like to know if there is any safe way to copy the TList elements into any other TList to a specific position and with a specific length. Should I just assign the elements of the list1 to list2 or is there any functionality out there I'm not aware of that handles that more accurate? Thanks for taking your time. 回答1: If your intention is to REPLACE items rather than to insert them at a given position, then the answer is that there is no direct mechanism and iterative assignment is the

Using Angle Brackets (I have seen people using TList<PSomething>)

倾然丶 夕夏残阳落幕 提交于 2019-12-07 23:21:14
问题 I see people declaring their TLists like MyList : TList<PSomeType>; Whereafter when they create it, they do MyList := TList<PSomeType>.Create; So I asume that by doing that, they won't have to typecast the MyList.Items[I] whenever they are using it, like: ShowMessage( PSomeType(MyList.Items[I]).SomeTextProperty ); So instead they would just do ShowMessage( MyList.Items[I].SomeTextProperty ); Is that correct? If so, then why can't I get it to work in Delphi 2010? I am trying exactly that -

generic TList of records with a sub list?

走远了吗. 提交于 2019-12-07 04:38:33
问题 I want to use a generic TList of records with a sub list in Delphi XE5: type TMyRecord=record Value1: Real; SubList: TList<Integer>; end; TMyListOfRecords=TList<TMyRecord>; var MyListOfRecords: TMyListOfRecords; Assignments to the field of the records are not possible: MyListOfRecords[0].Value1:=2.24; or MyListOfRecords[0].SubList:=TList<Integer>.Create; will result in "left side cannot be assigned to" error by the compiler. See also: How to modify TList<record> value? The following