Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
Output all keys and values from TFPGMap
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
This worries me about our...
by
PascalDragon
[
Today
at 09:51:53 pm]
In fpcsrc, many places ca...
by
AlexTP
[
Today
at 09:50:09 pm]
line number when error ha...
by
rcmz
[
Today
at 08:48:00 pm]
Unit Masks, matches funct...
by
Martin_fr
[
Today
at 07:31:00 pm]
Minimum and maximum value...
by
ASerge
[
Today
at 07:30:38 pm]
Access Violation
by
Lulu
[
Today
at 07:29:53 pm]
Fpcupdeluxe
by
DonAlfredo
[
Today
at 07:11:57 pm]
New book on Object Pascal
by
simone
[
Today
at 06:52:23 pm]
Help with search and repa...
by
avk
[
Today
at 06:26:23 pm]
Problem Installing CHM He...
by
Curt Carpenter
[
Today
at 05:50:37 pm]
Not visible soAllDirector...
by
LemonParty
[
Today
at 05:44:26 pm]
What is your current pet ...
by
TBMan
[
Today
at 05:07:28 pm]
How to detect if macOS ch...
by
Hansaplast
[
Today
at 04:37:22 pm]
Programmatic filtering in...
by
Bart
[
Today
at 04:00:49 pm]
[SOLVED] Box-and-whisker ...
by
apeoperaio
[
Today
at 03:40:35 pm]
Variable "xyz" doesn't no...
by
MarkMLl
[
Today
at 12:46:36 pm]
updated pc but.. worse [S...
by
rnervi
[
Today
at 12:34:48 pm]
Box-and-whisker plot with...
by
apeoperaio
[
Today
at 12:14:39 pm]
synedit
by
scasparz
[
Today
at 11:30:38 am]
Valgrind stops showing li...
by
Martin_fr
[
Today
at 11:13:07 am]
[SOLVED] Feature request:...
by
Hansaplast
[
Today
at 10:31:19 am]
Advanced Records Initiali...
by
Thaddy
[
Today
at 08:06:10 am]
AArch64. Slow program sta...
by
dbannon
[
Today
at 12:14:29 am]
Groupview uprgrade comple...
by
matthius
[November 12, 2025, 09:34:32 pm]
Playing video without to ...
by
Pe3s
[November 12, 2025, 09:02:55 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 306 times)
LemonParty
Sr. Member
Posts: 370
Output all keys and values from TFPGMap
«
on:
October 09, 2025, 07:33:46 pm »
Hello.
I want to output all keys and values from TFPGMap. How can I do that?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
cdbc
Hero Member
Posts: 2467
Re: Output all keys and values from TFPGMap
«
Reply #1 on:
October 09, 2025, 07:56:32 pm »
Hi
Does it have an 'Iterate' method, then use that...
It usually requires you to provide a procedure or method to call for each item in the map...
Maybe it's called 'ForEach'... that would be the same M.O. as above.
Regards Benny
eta: Forget iterating that list or its ancestors...! Just had a look
«
Last Edit: October 09, 2025, 08:10:01 pm by cdbc
»
Logged
If it ain't broke, don't fix it
PCLinuxOS(rolling release) 64bit -> KDE6 -> FPC 3.2.2 -> Lazarus 4.0 up until Jan 2025 from then on it's both above &: KDE6/QT6 -> FPC 3.3.1 -> Lazarus 4.99
Thausand
Sr. Member
Posts: 399
Re: Output all keys and values from TFPGMap
«
Reply #2 on:
October 09, 2025, 08:19:25 pm »
Quote from: LemonParty on October 09, 2025, 07:33:46 pm
I want to output all keys and values from TFPGMap. How can I do that?
Code: Pascal
[Select]
[+]
[-]
program
test
;
{$mode objfpc}{$h+}
uses
sysutils
,
fgl
;
type
TAMap
=
specialize TFPGMap<
string
,
integer>
;
var
Map
:
TAMap
;
n
,
i
:
integer
;
begin
Map
:
=
TAMap
.
Create
;
for
n
:
=
1
to
100
do
Map
.
Add
(
n
.
ToString
,
n
*
2
)
;
for
i
:
=
0
to
Map
.
Count
-
1
do
writeln
(
Map
.
Keys
[
i
]
,
' -> '
,
Map
.
Data
[
i
]
)
;
Map
.
Free
;
end
.
Logged
LemonParty
Sr. Member
Posts: 370
Re: Output all keys and values from TFPGMap
«
Reply #3 on:
October 10, 2025, 02:26:44 pm »
It works. Thank you.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
Output all keys and values from TFPGMap
TinyPortal
© 2005-2018