Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
TStringList & TStringArray(Solved)
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
OnKeyUp error sound
by
dseligo
[
Today
at 12:24:14 pm]
is there an internet conn...
by
af0815
[
Today
at 12:22:59 pm]
[Solved] Initialization s...
by
petevick
[
Today
at 12:20:48 pm]
VST summation time bugs
by
dseligo
[
Today
at 12:11:02 pm]
tvPlanit - how to presele...
by
wp
[
Today
at 11:54:40 am]
more UTF8 confusing
by
JuhaManninen
[
Today
at 11:28:56 am]
ScroogeXHTML 8.3 - RTF to...
by
mjustin
[
Today
at 11:09:13 am]
DatePointHintTool - inval...
by
Nicole
[
Today
at 11:08:53 am]
How to talk to a CDC USB ...
by
MarkMLl
[
Today
at 09:02:24 am]
Prevent computer logging ...
by
Davidous
[
Today
at 08:37:00 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: TStringList & TStringArray(Solved) (Read 225 times)
JLWest
Hero Member
Posts: 1259
TStringList & TStringArray(Solved)
«
on:
November 19, 2022, 05:58:54 pm »
I get an error on freeing the ItemArray but I have to create it. Seems wrong.
Code: Pascal
[Select]
[+]
[-]
Var
LList
:
TStringList
;
ItemArray
:
TStringArray
;
begin
LLIst
:
=
TStringList
.
Create
;
ItemArray
:
=
TStringArray
.
Create
;
...
finally
if
Assigned
(
LList
)
then
FreeAndNil
(
LList
)
;
if
Assigned
(
ItemArray
)
then
FreeAndNil
(
ItemArray
)
;
<
==
Error
«
Last Edit: November 19, 2022, 06:27:17 pm by JLWest
»
Logged
FPC 3.2.0, Lazarus IDE v2.0.4
Windows 10 Pro 32-GB
Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB
Thaddy
Hero Member
Posts: 12621
Re: TStringList & TStringArray
«
Reply #1 on:
November 19, 2022, 06:01:58 pm »
Since ItemArray is a dynamic array, you do not call free, let alone the evil freeandnil, but
setlength(ItemArray,0);
An array is not a class. There is a "constructor" but never a destructor.
«
Last Edit: November 19, 2022, 06:07:45 pm by Thaddy
»
Logged
The only thing I can say about Putin - born st Petersburg- is that he is indeed Russian, as opposed to Stalin, who was Georgian. Depending of historical time frame they could both be Lithuanian or Polish...even German. Shut him up!
JLWest
Hero Member
Posts: 1259
Re: TStringList & TStringArray
«
Reply #2 on:
November 19, 2022, 06:26:56 pm »
Ok- Corrected
Thanks
Logged
FPC 3.2.0, Lazarus IDE v2.0.4
Windows 10 Pro 32-GB
Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
TStringList & TStringArray(Solved)
TinyPortal
© 2005-2018