Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Incompatible types (https://www.delphipraxis.net/171921-incompatible-types.html)

WojTec 1. Dez 2012 21:20

Delphi-Version: 2010

Incompatible types
 
I have:

type TBoolans = array of Boolean;

Now function uses it. In var I have:

var Data: array [1..5] of Boolean.

Why I can't use it in function?
Is possible to make it usable (TBooleans and array of)?

jaenicke 1. Dez 2012 22:14

AW: Incompatible types
 
You have declared TBoolans as dynamic array, but your variable Data is a fixed size array.

You need to declare both as TBoolans to make them compatible.

uligerhardt 1. Dez 2012 22:25

AW: Incompatible types
 
If I understand you correctly you have
Delphi-Quellcode:
function Func(const AArray: TBooleans);
. I'd change that to
Delphi-Quellcode:
function Func(const AArray: array of Boolean);
. The first one accepts only dynamic arrays, the second all Boolean arrays. See Rudy's article about open arrays.

WojTec 2. Dez 2012 11:57

Re: Incompatible types
 
Ok, I'm no longer using TBooleans in parameters, just in results, thanks :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz