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
TTagEdit Component 1.2
by
astverskoy
[
Today
at 11:25:09 pm]
Dumb Problems Contest!
by
Bart
[
Today
at 11:08:05 pm]
Wikipedia pollution
by
Kays
[
Today
at 09:15:50 pm]
How to register a windows...
by
rca
[
Today
at 08:42:34 pm]
Corrupted strings
by
Aruna
[
Today
at 08:25:44 pm]
Convert string with Key-V...
by
Bart
[
Today
at 08:07:00 pm]
$ifdef highlighting
by
Thaddy
[
Today
at 07:26:54 pm]
Lazarus Trunc & macOS Tah...
by
Thaddy
[
Today
at 05:00:57 pm]
"F2": possible bug in IDE...
by
WooBean
[
Today
at 04:14:47 pm]
Please ask about the valu...
by
dseligo
[
Today
at 03:34:20 pm]
Need help converting a C+...
by
jamie
[
Today
at 03:18:52 pm]
TurboBird IBX
by
maurog
[
Today
at 02:56:32 pm]
Problem with TSQLQuery
by
sch61
[
Today
at 02:53:10 pm]
append new record to arra...
by
Warfley
[
Today
at 02:28:36 pm]
Lazarus broke my project
by
LatinoDaddy
[
Today
at 02:21:02 pm]
How to use nested classes
by
Thaddy
[
Today
at 02:03:44 pm]
Publish a LAMW app in F-d...
by
Joris
[
Today
at 01:49:23 pm]
Help with a TPages and TA...
by
AlexTP
[
Today
at 12:01:24 pm]
randomrange
by
BubikolRamios
[
Today
at 10:36:19 am]
Synedit wordwrap
by
Martin_fr
[
Today
at 09:42:04 am]
How to load read large CS...
by
Xenno
[
Today
at 05:43:10 am]
Uno, working demo (comput...
by
TBMan
[
Today
at 04:18:51 am]
[solved] fishing problem ...
by
speter
[
Today
at 03:36:39 am]
problen updating lazarus ...
by
LatinoDaddy
[
Today
at 02:48:20 am]
Need help with compiling ...
by
dbannon
[
Today
at 01:02:16 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Output all keys and values from TFPGMap (Read 338 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: 2509
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: 441
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