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
capture apl_exec stdout
by
toby
[
Today
at 11:07:32 pm]
GetObjectProp: Sample fro...
by
af0815
[
Today
at 10:50:27 pm]
error release when memo.s...
by
dseligo
[
Today
at 10:36:24 pm]
Want to see something fun...
by
OC DelGuy
[
Today
at 10:33:29 pm]
Best way to parse file.
by
Warfley
[
Today
at 09:14:30 pm]
lazreport load image from...
by
hamacker
[
Today
at 08:55:01 pm]
is there a "Lazarus.ini"?
by
qk
[
Today
at 08:53:20 pm]
pls advice for good style...
by
KodeZwerg
[
Today
at 08:17:23 pm]
GtoH
by
circular
[
Today
at 08:08:50 pm]
Question about GTK2 text ...
by
zeljko
[
Today
at 06:32:35 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: TStringList & TStringArray(Solved) (Read 220 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: 12543
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
Writing code in an overly complex way is usually merely a complete misunderstanding of the goal you are trying to achieve.
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