Board index » delphi » Array subscript declarations.
billboul...@one.nospam.net.au (Bill Boulton)
![]() Delphi Developer |
Wed, 21 Aug 2002 03:00:00 GMT
|
billboul...@one.nospam.net.au (Bill Boulton)
![]() Delphi Developer |
Wed, 21 Aug 2002 03:00:00 GMT
Array subscript declarations.
Hello Folks,
What precisely is the meaning of this type declaration: TSomething: array [0..0] of TThing; I think I saw it somewhere in Delphi 3 help but now I can't find it. I Help would be appreciated, |
Duncan Murdo
![]() Delphi Developer |
Wed, 21 Aug 2002 03:00:00 GMT
Re:Array subscript declarations.On Sat, 04 Mar 2000 01:26:20 GMT, billboul...@one.nospam.net.au (Bill QuoteBoulton) wrote: element in it, element 0. This is commonly used when the array is dynamically allocated: you don't know how many elements there will be at run time (you used GetMem to get some memory depending on run-time conditions), so you just declare one element. In my opinion this usage is bad style. It forces you to turn run-time A better declaration for a dynamically allocated array is TSomething: array [0..SomeBigNumber] of TThing; SomeBigNumber can be really huge, e.g. Maxint div sizeof (TThing). Duncan Murdoch |
Dr John Stockto
![]() Delphi Developer |
Wed, 21 Aug 2002 03:00:00 GMT
Re:Array subscript declarations.JRS: In article <38c05f6a.5146...@news.one.net.au> of Sat, 4 Mar 2000 01:26:20 in news:comp.lang.pascal.delphi.misc, Bill Boulton <billboulton Quote@one.nospam.net.au> wrote: It's a typedef of an array of a single element, with ":" in place of It's generally used for working with an array of indeterminate size, Instead, one should use TSomething= array [0..Lots] of TThing; where It should not be there, IMHO. My pas-extn.htm#VLarrs refers, though originally written for TP/BP. -- |
Dr John Stockto
![]() Delphi Developer |
Wed, 21 Aug 2002 03:00:00 GMT
Re:Array subscript declarations.JRS: In article <38c13df8.623...@newshost.uwo.ca> of Sat, 4 Mar 2000 16:52:34 in news:comp.lang.pascal.delphi.misc, Duncan Murdoch Quote<dmurd...@pair.com> wrote: proper run-time error checks. In longcalc.pas, I have a type Arr (imax is defined to be suitably All Arr are on the Heap, constructed to size with GetMem. Now (rapidly changing mind about exactly what to say) I do check Magic If I had had the wit, when I needed it, to add a similar marker byte In this case, access to the arrays Arr is time-significant; the program, -- |
Bill Boult
![]() Delphi Developer |
Sun, 25 Aug 2002 03:00:00 GMT
Re:Array subscript declarations.On Sat, 4 Mar 2000 20:40:23 +0000, Dr John Stockton Quote<j...@merlyn.demon.co.uk> wrote: Thanks Duncan & John. That's what I thought it was supposed to Bill Boulton. |