Re: Interface Question



On 2006-10-11, Rob Kennedy <me3@xxxxxxxxxxx> wrote:
question, since I don't really want to cover PChar in that article --
maybe in a more comprehensive article explaining the effects of the $X
compiler directive.

I'm not sure what you mean by "overindexing."

I don't if that is the correct term, because it is not strictly an array.
But I refered to the usage of the [] operator in a pchar like p[x].

For this msg, however I did a quick test, and found some results that were
surprising to me:

From the help: "The generic PChar represents a pointer to a Char" If that
was all, so if not "magic", pbyte should have the same properties as pchar.

I'll put in ^array[] of char and ^array[] of byte as reference

Type pbyte = ^byte;
chararr= array[0..0] of char;
pchararr = ^chararr;
bytearr= array[0..0] of byte;
pbytearr = ^bytearr;


var a : pbyte;
b : pchar;
c : char;
d : byte;
e : pchararr;
f : pbytearr;

begin
d:=a^;
d:=a^[0]; // array type required
d:=a[0] // array type required
c:=b^;
c:=b^[0]; // array type required
c:=b[6];
c:=e[0];
c:=e^[0];
d:=f[0];
d:=f^[0];
end;

That e[0] and f[0] compiled, surprised me. This makes pchar's behaviour less
odd, just the help wrong (it is closer to pchararr, not ^char)

.