[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

TStrings.. How ?

Posted on 1998-04-30
6
Medium Priority
?
434 Views
Last Modified: 2010-04-06
I want to create a TString object. How do I do that ?
0
Comment
Question by:Raptor062197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
pjdb earned 20 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

649 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