Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
questions concerning procedural types
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
IRC channel
Latest SVN
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Error on using hardware R...
by
tetrastes
[
Today
at 12:03:39 am]
lzRichEdit
by
jamie
[April 11, 2021, 11:54:59 pm]
How to reduce EXE program...
by
Fred vS
[April 11, 2021, 11:50:18 pm]
tstringlist handling file...
by
lucamar
[April 11, 2021, 11:43:01 pm]
Lazarus Release 2.0.12
by
antispam88
[April 11, 2021, 11:28:59 pm]
Image source for fpWeb / ...
by
RedOctober
[April 11, 2021, 11:22:32 pm]
Beggining with Pascal
by
marcov
[April 11, 2021, 11:09:39 pm]
How to determine, is user...
by
lucamar
[April 11, 2021, 10:58:15 pm]
Chasing the latest web cr...
by
ASBzone
[April 11, 2021, 10:48:22 pm]
Qt5 ATTabs painting probl...
by
Alextp
[April 11, 2021, 10:35:48 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: questions concerning procedural types (Read 265 times)
anonymousstranger
New Member
Posts: 49
questions concerning procedural types
«
on:
January 17, 2021, 02:54:42 am »
1) Given:
Code: Pascal
[Select]
[+]
[-]
Type
TOneArgCcall
=
Procedure
(
Var
X
:
integer
)
;
var
proc
:
TOneArgCcall
;
Procedure
printit
(
Var
X
:
Integer
)
;
begin
WriteLn
(
x
)
;
end
;
begin
Proc
:
=
@
printit
;
end
.
How does one pass a value into printit through proc? I'm kind of fuzzy on how this works.
2)Say you have a procedural type that references a procedure/function in a library. does the procedural type also require the "external" tag?
«
Last Edit: January 17, 2021, 03:05:41 am by anonymousstranger
»
Logged
Blaazen
Hero Member
Posts: 3034
POKE 54296,15
Re: questions concerning procedural types
«
Reply #1 on:
January 17, 2021, 03:22:35 am »
Since you pass variable x by reference (
var
), you have to write:
Code: Pascal
[Select]
[+]
[-]
var
i
:
Integer
;
begin
Proc
:
=
@
printit
;
i
:
=
5
;
Proc
(
i
)
;
end
;
i
can be global variable as well.
Don't know about external keyword.
Logged
Lazarus 2.1.0 r64546 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21
Try Eye-Candy Controls:
https://sourceforge.net/projects/eccontrols/files/
anonymousstranger
New Member
Posts: 49
Re: questions concerning procedural types
«
Reply #2 on:
January 17, 2021, 05:09:13 am »
cool
thanks.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
questions concerning procedural types
TinyPortal
© 2005-2018