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
Why does the call via fun...
by
Thaddy
[
Today
at 08:57:45 am]
LCL Web Native with D2Bri...
by
egsuh
[
Today
at 08:10:14 am]
Access Violation - Databa...
by
Xenno
[
Today
at 06:21:52 am]
Recomendations for conver...
by
egsuh
[
Today
at 04:39:30 am]
Error: Enumeration symbol...
by
440bx
[
Today
at 03:41:22 am]
Question re. FCL's ssocke...
by
Curt Carpenter
[
Today
at 12:22:45 am]
SpkToolbar custom update
by
wp
[December 14, 2025, 11:55:55 pm]
TLazSerial : serial port ...
by
tetrastes
[December 14, 2025, 09:57:52 pm]
[hacked for now] Changing...
by
jamie
[December 14, 2025, 09:00:23 pm]
MVP made easier.
by
cdbc
[December 14, 2025, 05:14:40 pm]
Lazarus is not working
by
Fred vS
[December 14, 2025, 05:14:20 pm]
TIBDataSet "Closing"? on ...
by
RedOctober
[December 14, 2025, 04:52:18 pm]
Running External Tools
by
JuhaManninen
[December 14, 2025, 04:08:28 pm]
The start of yet another ...
by
TBMan
[December 14, 2025, 03:16:21 pm]
Need help with Runcommand...
by
marcov
[December 14, 2025, 12:46:25 pm]
Military Grade Directives
by
Thaddy
[December 14, 2025, 11:46:44 am]
Cannot find Online Packag...
by
Thaddy
[December 14, 2025, 11:37:58 am]
Anyone interested in help...
by
ad1mt
[December 14, 2025, 08:56:20 am]
Hashing pointers by using...
by
440bx
[December 14, 2025, 03:16:33 am]
exception external SIGSEG...
by
dseligo
[December 14, 2025, 02:24:28 am]
[SOLVED] Is this a compil...
by
jamie
[December 14, 2025, 01:46:54 am]
Problem installing LazPro...
by
peter.dell
[December 14, 2025, 01:32:53 am]
AI interactions
by
Joanna
[December 13, 2025, 11:47:24 pm]
project - count source li...
by
bobonwhidbey
[December 13, 2025, 10:30:31 pm]
FPC 3.2.4-rc1 available
by
PeterBB
[December 13, 2025, 08:31:32 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 350 times)
LemonParty
Sr. Member
Posts: 391
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: 2531
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
Sr. Member
Posts: 448
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: 391
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