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
Lazarus undead repository...
by
sh17
[
Today
at 05:14:06 am]
TlsLib4Pascal
by
Tomxe
[
Today
at 04:26:49 am]
[Qt5/Qt6] JPSupport-Qt: J...
by
szlbz
[
Today
at 03:21:56 am]
Extended and XML Frames o...
by
matthius
[
Today
at 01:01:09 am]
var vs out (including "co...
by
440bx
[
Today
at 12:56:32 am]
Which Linux version
by
cdbc
[August 12, 2026, 11:22:16 pm]
Strangely - Not a questio...
by
Bart
[August 12, 2026, 10:26:58 pm]
Selected Text get number ...
by
Martin_fr
[August 12, 2026, 09:47:56 pm]
To DebugLn or not to Debu...
by
Martin_fr
[August 12, 2026, 09:01:02 pm]
Unleashed Pascal (async/a...
by
Martin_fr
[August 12, 2026, 08:54:07 pm]
New Big Integer library i...
by
ad1mt
[August 12, 2026, 07:16:56 pm]
The best name for procedu...
by
LemonParty
[August 12, 2026, 07:02:53 pm]
Why does Free Pascal use ...
by
440bx
[August 12, 2026, 07:02:28 pm]
[RE-SOLVED] Splitting an ...
by
madref
[August 12, 2026, 04:58:26 pm]
'ReadStr' ?
by
J-G
[August 12, 2026, 03:37:39 pm]
Fpcupdeluxe
by
DonAlfredo
[August 12, 2026, 02:20:26 pm]
Trayslate 1.5.0 - Free tr...
by
AlexanderT
[August 12, 2026, 02:18:28 pm]
enable easy marker moveme...
by
Paolo
[August 12, 2026, 01:30:39 pm]
Error installing EyeCandy...
by
JuhaManninen
[August 12, 2026, 08:46:00 am]
LRS Explorer
by
CM630
[August 11, 2026, 11:33:24 pm]
Identify network devices
by
Warfley
[August 11, 2026, 10:55:13 pm]
Lazarus Bugfix Release 4....
by
geraldholdsworth
[August 11, 2026, 04:55:42 pm]
[Solved[ How to define th...
by
Mike.Cornflake
[August 11, 2026, 03:42:11 pm]
Dataset EnableControls/Di...
by
Mike.Cornflake
[August 11, 2026, 03:37:42 pm]
Debugging in a real termi...
by
Martin_fr
[August 11, 2026, 02:59:09 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 624 times)
LemonParty
Hero Member
Posts: 608
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: 2923
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/QT6 -> FPC Release -> Lazarus Release & FPC Main -> Lazarus Main
Thausand
Hero Member
Posts: 593
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
A docile goblin always follow HERMES.md
LemonParty
Hero Member
Posts: 608
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