Dave Murray wrote:
> What does a type declaration like this mean?
>
> Adapter : array [0..0] of IP_ADAPTER_INDEX_MAP;
>
> Why is the index range 0..0?
Maybe the array really is supposed to have only one element?
> I'm trying to iterate through this array in a while loop and sometimes
> get a range error when I know there are still entries left.
As Jonas mentioned, it's a dynamic array. I'm guessing that declaration
actually appears as part of a record, not as a standalone variable. And
you never declare a variable of that record type, do you? Instead, you
declare a pointer to that type, and then either you allocate a block of
memory dynamically, or Windows returns a pointer.
If you get run-time errors while accessing elements of the array, then
you need to turn off range checking for that area of the code:
{$R-}
for i := 0 to Pred(ArrayLength) do
Adapter[i].abc := xyz;
{$R+}
If you get compile-time errors, then you need to do one of two things:
1. Introduce a variable, so instead of "Adapter[2]" you have "x := 2;
Adapter[x]."
2. Adjust the array declaration to include at least as many elements as
you plan to refer to with hard-coded constants. If you need to access
element 2 as "Adapter[2]," then use a range of at least 0..2. You can
still go beyond that range at run time with the loop structure above.
There's just no way to disable compile-time range checking.
--
Rob
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/