I want to initialise an array like this -
Const MyArray : Array[0..0] Of TGUID = (IInterface);
But it results in -
[DCC Error] Test.pas(10): E2010 Incompatible types: 'TGUID' and 'string'
So to see what would happen I tried this -
Const MyArray : Array[0..0] Of String = (IInterface);
Which results in this!
[DCC Error] Test.pas(10): E2010 Incompatible types: 'string' and 'TGUID'
How strange! Surely IInterface is one or the other, but it seems to stubbornly transform into the wrong type.
You can pull the GUIDs from the interface declarations and declare them as (string) constants. You can then use these constants in your interface declarations and your array constant declarations. The compiler accepts valid GUID strings where TGUID is expected. Invalid strings result in E2204 "Improper GUID syntax" compile error.
const
MyGuid1 = '{99BDAB12-B1B6-41B0-9BF1-2C1DB3D8EC70}';
MyGuid2 = '{8C7CD303-8D81-469B-99ED-E1F163E9036F}';
type
IMyInterface1 = interface
[MyGuid1]
end;
IMyInterface2 = interface
[MyGuid2]
end;
const
MyArray: array[0..1] of TGUID = (MyGuid1, MyGuid2);
If you use a const array you have to set it up with const values like this:
const GuidArray: array[0..0] of TGuid=
('{84DBCC66-72AA-4806-AE28-B55FC5B83FC8}');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With