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
Elite Arcade
by
Guva
[
Today
at 11:25:29 pm]
Freepascal
by
marcelomaurinmartins@gmai
[
Today
at 11:24:44 pm]
International Pascal Cong...
by
vincococka
[
Today
at 11:18:49 pm]
Printing on HP Smart Tank
by
JerryHudson
[
Today
at 10:22:12 pm]
Help needed on how to do ...
by
cdbc
[
Today
at 08:38:38 pm]
TDateTimePicker - Make th...
by
wp
[
Today
at 08:20:10 pm]
TCollection wiki entry
by
korba812
[
Today
at 08:18:03 pm]
Why is my program freezin...
by
paweld
[
Today
at 07:19:46 pm]
is there PDS reader/expor...
by
jamie
[
Today
at 07:01:12 pm]
UI app to work with SQLit...
by
LeP
[
Today
at 06:44:26 pm]
Fpcupdeluxe
by
cdbc
[
Today
at 06:40:29 pm]
weird error message
by
jamie
[
Today
at 06:37:01 pm]
Como compilar uma lib par...
by
marcelomaurinmartins@gmai
[
Today
at 06:24:51 pm]
Desenvolvimento visual pa...
by
marcelomaurinmartins@gmai
[
Today
at 06:19:16 pm]
OpenDocument('Filename') ...
by
J-G
[
Today
at 06:13:03 pm]
TTL Record Count, i.e. a ...
by
1HuntnMan
[
Today
at 06:05:29 pm]
Using callback
by
LemonParty
[
Today
at 05:43:15 pm]
equivalent to C/C++ "offs...
by
jamie
[
Today
at 12:58:11 pm]
Source Editor Collapsed P...
by
J-G
[
Today
at 11:17:14 am]
Habari STOMP Clients for ...
by
mjustin
[
Today
at 11:15:54 am]
Questions on slight diffe...
by
egsuh
[
Today
at 09:45:30 am]
Have anybody used Horse f...
by
egsuh
[
Today
at 08:31:21 am]
Problems with creating a ...
by
jamie
[
Today
at 12:10:44 am]
val return code
by
Paolo
[July 10, 2026, 10:58:32 pm]
Gtk3 becomes default widg...
by
PascalDragon
[July 10, 2026, 09:59:25 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 618 times)
LemonParty
Hero Member
Posts: 555
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: 2855
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: 560
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: 555
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