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
error release when memo.s...
by
dseligo
[
Today
at 05:40:29 am]
Is there a function calle...
by
Bogen85
[
Today
at 05:33:40 am]
Controls inside the form ...
by
Ecsa
[
Today
at 04:02:37 am]
Theo's Searchbar plugin f...
by
Curt Carpenter
[
Today
at 03:54:33 am]
Search panel plugin for t...
by
Curt Carpenter
[
Today
at 03:51:49 am]
Question about GTK2 text ...
by
tomitomy
[
Today
at 02:25:17 am]
lazreport load image from...
by
dseligo
[
Today
at 01:41:08 am]
pls advice for good style...
by
dseligo
[
Today
at 01:19:35 am]
Best way to parse file.
by
Kays
[
Today
at 12:56:50 am]
capture apl_exec stdout
by
440bx
[
Today
at 12:28:28 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: TStringList & TStringArray(Solved) (Read 222 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