tstringlist

tStringList passing in C# to Delphi DLL

I have a Delphi DLL with a function defined as: function SubmitJobStringList(joblist: tStringList; var jobno: Integer): Integer; I am calling this from C#. How do I declare the first parameter as a tStringList does not exist in C#. I currently have the declaration as: [DllImport("opt7bja.dll", CharSet = CharSet.Ansi, CallingConvention...

Want to read a file to a TStringList

Hi! Yes I want to read a simple a logfile into a TStringList and that is easy done with LoadFromFile. But the problem is that the file can be already opened by another program at the same time so an exception may appear. I have tried to use: FileMode := fmShareCompat; But it won't work. I have also tried to use: fFilePath := fPathL...

Wrapping TStringList in a Record

I tend to use Delphi's TStringList for text manipulation, so I write a lot of procedures/functions like: var TempList: TStringList; begin TempList:= TStringList.Create; try // blah blah blah do stuff with TempList finally TempList.Free; end; end; It would be nice to cut out the creation and freeing for such a co...

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

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 t...

Replacement for TStringList in Delphi Prism.

Hello, 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. ...

Error in Free TStringList Object

procedure FreeListObjects( l : TStrings); var i : integer; BEGIN FOR i := 0 TO l.Count -1 DO BEGIN l.Objects[i].Free; l.Objects[i] := NIL; END; end; PROCEDURE StringListAdd; VAR i : INTEGER; Code : LONGWORD; BEGIN l := Classes.TstringLIST.CREATE; FOR i := 0 TO 4 DO BEGIN Code := i ; l.AddObjec...

Problem adding lots of strings to a TStringList

Hello!!! I have a problem adding strings to a TStringList. I've searched other posts but couldn't find an answer to this. What I'm trying to do is to add a big amount of strings to a TStringList (more than 14000) but somewhere in the process I get an EAccessViolation. Here's the code I'm using: procedure TForm1.FormCreate(Sender: TOb...

Delphi stringlist finding negative keyword in list

I have two string lists that I'm working with. One that has a list of keywords, and then another that has a list of negative keywords. I want to be able to search through the list and pick out the list items that do not contain the negative keyword and output to a third keyword list. I was using the AnsiPos function but that found the...

How can I get TStringList to sort differently in Delphi

I have a simple TStringList. I do a TStringList.Sort on it. Then I notice that the underscore "_" sorts before the capital letter "A". This was in contrast to a third party package that was sorting the same text and sorted _ after A. According to the ANSI character set, A-Z are characters 65 - 90 and _ is 95. So it looks like the 3rd ...

Sort a string list: Move or exchange items only

In Delphi / Pascal I would like to sort a TStringList alphabetically. But for this purpose, I can only use the following two methods: Move: Moves a string from one index position to another, shifting other strings around as appropriate. Exchange: Swaps two strings in the list, as identified by their index positions. How could I do thi...

Comparing and sorting Unicode filenames

Using Delphi 2007 and TMS components for Unicode utils and interface (upgrading to Delphi 2009 for Unicode support is not an option). I'm storing a list of filenames in a string list (TTntStringList). It's sorted and case insensitive. The default sort routine uses CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, ...) to compare stri...

TStringList, Dynamic Array or Linked List in Delphi?

I have a choice. I have a number of already ordered strings that I need to store and access. It looks like I can choose between using: A TStringList A Dynamic Array of strings, and A Linked List of strings (singly linked) and Alan in his comment suggested I also add to the choices: TList<string> In what circumstances is each of the...

Any way to get TStringList.CommaText to not escape commas with quotes?

I'm doing some work with code generation, and one of the things I need to do is create a function call where one of the parameters is a function call, like so: result := Func1(x, y, Func2(a, b, c)); TStringList.CommaText is very useful for generating the parameter lists, but when I traverse the tree to build the outer function call, w...

Parsing a string using a delimiter to a TStringList, seems to also parse on spaces (Delphi)

I have a simple string which is delimited by some character, let's say a comma. I should be able to create a TStringList and set it's delimiter to a comma then set the DelimitedText to the text I want to parse and it should be automaticlly parsed. The problem is when I look at the output it also includes spaces as delimiters and chops ...

Delphi TStringList wrapper to implement on-the-fly compression

I have an application for storing many strings in a TStringList. The strings will be largely similar to one another and it occurs to me that one could compress them on the fly - i.e. store a given string in terms of a mixture of unique text fragments plus references to previously stored fragments. StringLists such as lists of fully-qua...

Stringlist with delimiter as a string ?

I have an attribute called HistoryText in a object that is stored as a string. I want to show all rows in a grid. I should be able to delete and edit rows in the grid. The format is: 16.5.2003-$-12:09-$-anna-$-Organization created 2.6.2005-$-13:03-$-jimmy-$-Organization edited 19.12.2005-$-13:33-$-madeleine-$-Organization edited So ea...

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

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...

How to impliment a stringlist property in a custom delphi component?

I am creating my first custom Delphi component. Its basically a custom Tpanel with header and lines text displayed on it. I want to be able to add multiple lines text using a stringlist. When testing the component I cannot get the text lines to display on the panel when adding lines: NewLinesText.add('line1 text') It does however wo...