Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Is there a $modeswitch to enable initialized variables in {$mode tp} ?
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
IRC channel
GIT
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
FpDebug questions
by
Martin_fr
[
Today
at 11:25:02 am]
Parameter passing odditie...
by
Thaddy
[
Today
at 11:23:20 am]
splitting an image
by
Dzandaa
[
Today
at 11:15:40 am]
how to tweek fpmake to co...
by
marcov
[
Today
at 10:35:11 am]
Can function be used for ...
by
Thaddy
[
Today
at 10:24:31 am]
Why isn't TTIRadioGroup's...
by
egsuh
[
Today
at 08:09:35 am]
Lazarus for Windows on aa...
by
Wallaby
[April 23, 2024, 11:46:56 pm]
(Solved) TIndexedAVLTree ...
by
lainz
[April 23, 2024, 10:49:03 pm]
Demo Scene Picture sinwav...
by
KodeZwerg
[April 23, 2024, 10:26:21 pm]
fkInternalCalc
by
zraja
[April 23, 2024, 09:31:07 pm]
A fairly simple sound sol...
by
KodeZwerg
[April 23, 2024, 09:23:37 pm]
add new targets to make
by
marcov
[April 23, 2024, 08:38:42 pm]
Quirky windows
by
ASerge
[April 23, 2024, 07:07:16 pm]
[Request] Demo Scene Sub ...
by
Gigatron
[April 23, 2024, 06:29:39 pm]
Unlocking Files
by
KodeZwerg
[April 23, 2024, 06:03:08 pm]
[SOLVED] trunk bug for mi...
by
Key-Real
[April 23, 2024, 05:56:32 pm]
Demo Scene Bitmap Font Sc...
by
Gigatron
[April 23, 2024, 05:56:27 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[April 23, 2024, 05:43:11 pm]
Generics - correct syntax
by
Thaddy
[April 23, 2024, 05:40:59 pm]
InstallAware Using Lazaru...
by
msintle
[April 23, 2024, 05:26:36 pm]
Xcode Command Line Tools ...
by
Joseph
[April 23, 2024, 05:16:39 pm]
Offical launch of the 1 B...
by
Hartmut
[April 23, 2024, 04:49:29 pm]
what to do if my target M...
by
nickysn
[April 23, 2024, 04:16:02 pm]
compiler error in unit
by
paule32
[April 23, 2024, 03:49:50 pm]
Multithreading - synchron...
by
mika
[April 23, 2024, 01:48:51 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Is there a $modeswitch to enable initialized variables in {$mode tp} ? (Read 1045 times)
Hartmut
Hero Member
Posts: 751
[SOLVED] Is there a $modeswitch to enable initialized variables in {$mode tp} ?
«
on:
January 17, 2020, 05:21:23 pm »
I want to use an initialized array variable in {$mode tp} like:
Code: Pascal
[Select]
[+]
[-]
{$mode tp}
var
a
:
array
of
integer
=
nil
;
This is not allowed (FPC 3.2.0). But for the most features of {$mode delphi} or {$mode objfpc} there is a {$modeswitch xyz} directive to enable it. In
https://www.freepascal.org/docs-html/prog/progsu105.html
I didn't find it. Does it not exist?
Thanks in advance.
«
Last Edit: January 17, 2020, 07:26:37 pm by Hartmut
»
Logged
Thaddy
Hero Member
Posts: 14384
Sensorship about opinions does not belong here.
Re: Is there a $modeswitch to enable initialized variables in {$mode tp} ?
«
Reply #1 on:
January 17, 2020, 05:23:34 pm »
mode tp doesn't know about dynamic arrays. Use either mode delphi or mode objfpc (syntax differs)
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
Hartmut
Hero Member
Posts: 751
Re: Is there a $modeswitch to enable initialized variables in {$mode tp} ?
«
Reply #2 on:
January 17, 2020, 05:30:41 pm »
But this compiles (FPC 3.0.4):
Code: Pascal
[Select]
[+]
[-]
{$mode tp}
var
a
:
array
of
integer
;
i
:
integer
;
begin
SetLength
(
a
,
10
)
;
for
i
:
=
0
to
High
(
a
)
-
1
do
a
[
i
]
:
=
i
;
end
.
Logged
Jonas Maebe
Hero Member
Posts: 1059
Re: Is there a $modeswitch to enable initialized variables in {$mode tp} ?
«
Reply #3 on:
January 17, 2020, 05:45:20 pm »
No, there is no modeswitch for this functionality.
Logged
Hartmut
Hero Member
Posts: 751
Re: Is there a $modeswitch to enable initialized variables in {$mode tp} ?
«
Reply #4 on:
January 17, 2020, 07:26:03 pm »
This is sad news (but that's not your fault ;-). Thanks for your help, Jonas.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Is there a $modeswitch to enable initialized variables in {$mode tp} ?
TinyPortal
© 2005-2018