SRL Archive - Help and Support

TStrings!


Santa_Clause

2007-08-01 02:19:20

I know what strings are. A couple of people said TStrings was an Array Of Strings, but then Boreas and NewToAutoing said that would be TStringArray.

Anyone mind explaining TStrings to me? Perhaps on MSN?

SKy Scripter

2007-08-01 04:10:18

this is What a TString Array would be…


program New;
var
S : TStringArray;
i : integer;

begin
S := ['Hey', 'Hah', 'Blah'];
for i := 0 to Length(s)-1 do
Writeln(S[i]);
end.


and TString is used for like objects..
like ListBox.TString(Items).Add('hey');


program New;



var
MainForm : TForm;
ListBox : TListBox;


procedure InitForm;
begin
MainForm := CreateForm;
MainForm.SetBounds(0, 0, 300, 200);
MainForm.POSITION:= poDesktopCenter;
MainForm.BORDERICONS:= [biMinimize, biSystemMenu];
MainForm.BORDERSTYLE:= bsSingle;
MainForm.Color := 0;
MainForm.Caption := '';

ListBox := TListBox.Create(MainForm);
ListBox.Parent := Mainform;
ListBox.SetBounds(10, 10, 100, 100);
ListBox.Items.Add('Add'); // Items = TString
ListBox.Items.Append('Muhahha');

MainForm.ShowModal;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;


begin
try
SafeInitForm;

finally
FreeForm(MainForm)

except
Writeln('ERROR: With Loading');
end;

end.

R0b0t1

2007-08-08 21:44:30

If you know what types are, its a type string.

Santa_Clause

2007-08-08 21:49:58

Time for me to read a tutorial then…

R0b0t1

2007-08-08 22:01:49

Well. to sum it up, a type is like an array.

Like the type


TUser;

is what holds the variables found in the


Var
Players: Array [0..?] of TUser

Player array.

Spky

2007-08-08 22:11:06

It's not a 'type string'. It's an object that is used to store and manipulate an array of strings. It can also hold other objects (I think).

For example:


var
MyStringList : TStringList;

begin
MyStringList:= TStringList.Create; { Our array is now [] }
MyStringList.Append('1'); { Now ['1'] }
MyStringList.Append('2'); { Now ['1', '2'] }
MyStringList.Insert('0', 1); { Now ['0', '1', '3'] }
MyStringList.Delete(3); { Now ['0', '1'] }

Writeln(MyStringList[0]); { Will write "0" }
end.

Sorry if thats using wrong params or w/e. I don't have SCAR on me.

R0b0t1

2007-08-08 22:43:09

Ohh! I thought it was a type because of the T….

Santa_Clause

2007-08-09 00:03:18

Ooo, that helps a bit.

SKy Scripter

2007-08-09 01:53:59

its a Class Type :)
(im pretty sure)