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
Postgres, ZEOS and Visual...
by
wp
[
Today
at 01:36:44 pm]
Help with search and repa...
by
Thausand
[
Today
at 12:41:33 pm]
Lazarus Bugfix Release 4...
by
Martin_fr
[
Today
at 12:24:59 pm]
Valgrind stops showing li...
by
Martin_fr
[
Today
at 12:09:06 pm]
Form scaling aspect ratio
by
jamie
[
Today
at 12:07:58 pm]
manufacturing sim (inc)
by
speter
[
Today
at 11:38:56 am]
Variable "xyz" doesn't no...
by
Thaddy
[
Today
at 11:17:25 am]
In fpcsrc, many places ca...
by
Thaddy
[
Today
at 09:41:38 am]
Can't I highlight part of...
by
Martin_fr
[
Today
at 08:43:03 am]
Mapping Images Like Odome...
by
SandyG
[
Today
at 06:56:55 am]
Access Violation
by
Thaddy
[
Today
at 06:23:59 am]
Problem Installing CHM He...
by
dbannon
[
Today
at 01:53:29 am]
This worries me about our...
by
dbannon
[
Today
at 01:38:35 am]
[SOLVED] Heaptrc reports ...
by
jamie
[
Today
at 12:48:49 am]
New book on Object Pascal
by
TBMan
[
Today
at 12:39:00 am]
Programmatic filtering in...
by
jamie
[November 13, 2025, 11:30:59 pm]
Fpcupdeluxe
by
Cascade
[November 13, 2025, 10:46:00 pm]
line number when error ha...
by
Martin_fr
[November 13, 2025, 10:37:19 pm]
Unit Masks, matches funct...
by
Martin_fr
[November 13, 2025, 07:31:00 pm]
Minimum and maximum value...
by
ASerge
[November 13, 2025, 07:30:38 pm]
Not visible soAllDirector...
by
LemonParty
[November 13, 2025, 05:44:26 pm]
What is your current pet ...
by
TBMan
[November 13, 2025, 05:07:28 pm]
How to detect if macOS ch...
by
Hansaplast
[November 13, 2025, 04:37:22 pm]
[SOLVED] Box-and-whisker ...
by
apeoperaio
[November 13, 2025, 03:40:35 pm]
updated pc but.. worse [S...
by
rnervi
[November 13, 2025, 12:34:48 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 307 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: 2469
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: 403
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