Solved

TStrings.. How ?

Posted on 1998-04-30
6
427 Views
Last Modified: 2010-04-06
I want to create a TString object. How do I do that ?
0
Comment
Question by:Raptor062197
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
pjdb earned 10 total points
ID: 1340001
TString? I assume you mean a list of string so that's a TStringList.

Use the following :

Procedure MyTest;
Var
  MyStrings:TStringList;
procedure TForm1.Button3Click(Sender: TObject);
Begin
  MyStrings:=TStringList.Create;  {Create the TStrings object}
{Do your job}
{for example :}
  MyStrings.Clear;
  MyStrings.add('test');

  MyStrings.Free; {destroy the TStrings object and free memory}
End;

JDB
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1340002
I will assume by TString you really mean TStingList???
useing a string is as simple as doing
Var
  MyString : string

MyString := 'My Big Ass String';

To use a String List you need to do a bit more

Var
  MyStringList : TStringList;

To Assign a value do this

MyString := TStringList.Create;
MyString.Add('My Big Ass String');

Then When you are done with it do a
MyString.Free;

Hope this is what you needed.



0
 

Author Comment

by:Raptor062197
ID: 1340003
I mean TStrings. (I want to make a text for a RichEdit dynamically and store it to the RichEdit.Lines property)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:pjdb
ID: 1340004
As far as i know, you need to use a TStringList and when you want to put the strings to the TRichEdit, then use RichEdit1.Strings:=MyStrings;
You can't use a TStrings object directly (In Delphi help it is written : "To maintain a list of strings outside of a control, use a string list object (TStringList).")

JDB
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1340005
what I think you really mean it a TStringStream this is what one normaly uses to get the Rich text proporties out of a RTFEdit.  This is because if you say
var
 MyFattyString : string
begin
  MyFattyString := RTFEdit1.Text
end

MyFattyString is just a string of text with none of the formating stuff in it.

so I think you want to do something like this

var
  MyStream : TStringStream;
begin
  MyStream := TStringStream.Create('');
  RtfTextEdit.SaveToStream(MyStream);
  MyDB.FieldByName('CPNote').AsString := MyStream.DataString;
  MyStream.Free;
end;

then when you want the text to go back to the RTF you can use it as a plane old string then
    RtfTextEdit.Text := MyDB.FieldByName('CPNote').AsString;


Hope this is what you need because you'll have to put the points to 100 before I come back in here :)

0
 

Author Comment

by:Raptor062197
ID: 1340006
var T : TStringList;

  T:= TStringlist.Create;
  T.clear;
  T.add('Hallo');
  T.add('Test');
  Form1.RichEdit1.text:= T.text;

That worked for me. I wanted to create some text and let it display in a RichEdit.
The error I was getting was because I did the above stuff in the onCreate handler of Form2.
Now that I put it into Form, it works
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
build html 5 client that connect to indy Tidtcpserver 3 350
Machine not responding during CopyFile() 3 88
Magic Software info 18 124
drawing animated level bar based on numbers 3 86
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now