Solved

TStrings.. How ?

Posted on 1998-04-30
6
426 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

17 Experts available now in Live!

Get 1:1 Help Now