tstringlist

Delphi for loops and StringList Errors

▼魔方 西西 提交于 2020-05-30 03:58:51
问题 Ok guys, I've been trying to find out every possible mistake i'm making but I give up... I need help! What I'm writing is an app to manage rentals for my job and when the date is past, my app removes the name from 2 text files. I wrote 3 little functions(procedures) to make this work. Here: This one loads from dates.dat file and remove the line containing the name of the employee. procedure remDate(emp: String);/// Removes employee from date file var pos1, i: integer; dateList: TStringList;

How can I search faster for name/value pairs in a Delphi TStringList?

不羁岁月 提交于 2019-12-31 17:59:00
问题 I implemented language translation in an application by putting all strings at runtime in a TStringList with: procedure PopulateStringList; begin EnglishStringList.Append('CAN_T_FIND_FILE=It is not possible to find the file'); EnglishStringList.Append('DUMMY=Just a dummy record'); // total of 2000 record appended in the same way EnglishStringList.Sorted := True; // Updated comment: this is USELESS! end; Then I get the translation using: function GetTranslation(ResStr:String):String; var

Strange EOutOfMemory exception using TStringList

柔情痞子 提交于 2019-12-25 09:32:44
问题 I have a system that loads some text files that are zipped into a ".log" file and parse then into informational classes using multiple threads that each deals with a different file and adds the parsed objects to a list. The file is loaded using TStringList, since it was the fastest method that I tested. The number of text files is variable but normally I have to deal with something between 5 to 8 files ranging from 50Mb to 120Mb in one incursion. My problem: The user can load the .log files

TStringList of objects taking up tons of memory in Delphi XE

左心房为你撑大大i 提交于 2019-12-19 03:12:16
问题 I'm working on a simulation program. One of the first things the program does is read in a huge file (28 mb, about 79'000 lines,), parse each line (about 150 fields), create a class for the object, and add it to a TStringList. It also reads in another file, which adds more objects during the run. At the end, it ends up being about 85'000 objects. I was working with Delphi 2007, and the program used a lot of memory, but it ran OK. I upgraded to Delphi XE, and migrated the program over and now

Delphi: StringList Delimiter is always a space character even if Delimiter is set

百般思念 提交于 2019-12-17 15:59:21
问题 I am having trouble with the delimiter in the TStringList Class. Take a look: var s: string; sl: TStringList; begin sl := TStringList.Create; s := 'Users^foo bar^bar foo^foobar^barfoo'; sl.Delimiter := '^'; sl.DelimitedText := s; ShowMessage(sl[1]); end; sl[1] SHOULD return 'foo bar' sl[1] DOES return 'foo' It seems that the delimiter is now '^' AND ' ' Any ideas? 回答1: You should set s1.StrictDelimiter := True for spaces not to be considered delimiters, more info here. Since you work in a

How to convert List<string> to xml document in c#

泪湿孤枕 提交于 2019-12-13 23:08:29
问题 I would like to convert the List to a xml document in c#. My code is as follows: List<string> BugWSResponseList1 = new List<string>(); Logger.Write("\n\n" + DateTime.Now + " : " + " : START : Creation of a set of Bugs via bug.Add API"); BugWSResponseList1 = CreateBugs(FilePath_EXPRESS_API_BugAdd_CreateBugs_DataFile); Logger.Write("\n\n" + DateTime.Now + " : " + " : END : Creation of a set of Bugs via bug.Add API"); I have been trying to convert the list response to string and then tried to

Are there good practices if any avoiding out of bounds index error when looping TStringList items?

狂风中的少年 提交于 2019-12-13 02:37:56
问题 :) First thing, my code procedure TForm1.Button3Click(Sender: TObject); var tempId,i:integer; begin tempId:=strtoint(edit5.Text); plik:=TStringList.Create; plik.LoadFromFile('.\klienci\'+linia_klient[id+1]+'.txt'); if (plik.Count=1) then begin label6.Caption:='then'; if (tempId=StrToInt(plik[0])) then begin Label6.Caption:='Zwrócono'; plik.Delete(0); end end else for i:=0 to plik.Count-2 do begin if (tempId=StrToInt(plik[i])) then begin Label6.Caption:='Zwrócono'; plik.Delete(i); end; end;

Replacement for TStringList in Delphi Prism.

天大地大妈咪最大 提交于 2019-12-12 11:23:35
问题 I am migrating an application written in Delphi 2007 .Net to Delphi Prism, which is the best option to replace the TStringList and TStrings class? Thanks in advance. Bye. 回答1: Just use the built in List types in the .NET framework, or the StringCollection. The easiest are the generic lists: List<String> But StringCollection has a few bits that the List does not have; you can read a bit about that in this thread. The advantage of using built-in .NET Framework classes, is that there is plenty

How can I loop through a delimited string and assign the contents of the string to local delphi variables?

烈酒焚心 提交于 2019-12-11 16:32:28
问题 I have written a Delphi function that loads data from a .dat file into a string list. It then decodes the string list and assigns to a string variable. The contents of the string use the '#' symbol as a separator. How can I then take the contents of this string and then assign its contents to local variables? // Function loads data from a dat file and assigns to a String List. function TfrmMain.LoadFromFile; var index, Count : integer; profileFile, DecodedString : string; begin // Open a file

How Can I Replace StringList.Sort with a Stable Sort in Delphi?

时光怂恿深爱的人放手 提交于 2019-12-10 18:35:50
问题 I'm doing a simple StringList.sort, but Delphi uses a QuickSort that is not a stable sort, meaning it may change the relative order of records with equal keys. I need to use a stable sort. What would be the easiest way for me to implement this? Mike W's answer might be the simplest way to do it without too much code change necessary. Thanks, Mike. 回答1: If you're not already using the Objects property of the string list a quick and dirty solution would be to store the original position in the