Board index » delphi » Dynamic Array Size
Edward Terng
![]() Delphi Developer |
Mon, 07 Dec 1998 03:00:00 GMT
|
Edward Terng
![]() Delphi Developer |
Mon, 07 Dec 1998 03:00:00 GMT
Dynamic Array SizeI would like to find out is there anyway I can manipulate the size of an array instead of pre-define it ? Something like : Ar : Array[n1..n2] where n1 and n2 is defined by program during execution. It will be even more interesting if I can increase or decrease the elements in the array. Thanks for any help in advance. Edward Terng |
l..
![]() Delphi Developer |
Mon, 07 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuoteEdward Terng <edte...@pc.jaring.my> wrote: ever did allow dynamic array allocation in this fashion, although both Algol and PL/I do. Novice Fortran programmer have claimed that you can do it, but that is (Now if you're running Algol on a Burrough's machine however you can |
Francisco A. Ocan~a Lar
![]() Delphi Developer |
Mon, 07 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuoteOn Thu, 20 Jun 1996, Edward Terng wrote: But, you can also mix them to obtain the appropiate solution to your problem: - Using an "array" structure based on the heap memory: { dato = type of the element of the "array" structure } puntero = ^dato; tindex = { e.g } byte; {type of index} narray = record Next, you wold have to design routines to handle this array - The following way is based on the OOP (Object Oriented narray = object procedure narray.init(var nn1: tindex); function narray.out-dato(i: tindex): dato; procedure narray.in-dato(var i: tindex; var d: dato); Yours faithfully Francisco Antonio Ocan~a Lara |
Mark Vaugh
![]() Delphi Developer |
Tue, 08 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeIn article <1996Jun20.012504.27...@arl.mil>, best (only?) way is to make an array class. here's an example using Type Const Type PVector = ^TVector; vMemAllocated : word; Elements : PVectorElements; Procedure PutElement(Index : integer; DataVal : float); Procedure Resize(NewStart, NewStop : integer); constructor TVector.Init(start, stop : integer); BEGIN {==TVector.Init==} destructor TVector.Done; BEGIN {==TVector.Done==} Procedure TVector.PutElement(Index : integer; DataVal : float); Function TVector.GetElement(Index : integer) : float; Procedure TVector.Resize(NewStart, NewStop : integer); this compiles okay, but I've never used this particular version Mark Vaughan ]- |
Mike Chap
![]() Delphi Developer |
Wed, 09 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeIn article <1996Jun20.012504.27...@arl.mil>, Quote>I would like to find out is there anyway I can manipulate the size of an Quote
Type TMyArr : Array[0..(65520 Div Sizeof(TMyStruct)] Of TMyStruct; Var Function MakeArray(num : Integer) : PMyArr; Procedure KillArray(theArr : PMyArr); ----------------------------------------------- Not the end of the earth but you can see it from |
Mike Copelan
![]() Delphi Developer |
Wed, 09 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuote> ]-I would like to find out is there anyway I can manipulate the size of an Turbo Pascal for many releases (prior to OOP), by declaring a maximum (or minumum) array type, a pointer to it, and allocating Heap memory specific to the program's execution. There is some inherent risk in using a mimimum array type ([0..0]), because you must override Range Checking to use it. An example which uses a "maximum array type": Type DAType = array[0..32760] of integer; |
Jacques Gu
![]() Delphi Developer |
Thu, 10 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuoteMike Copeland wrote: assignment of the type DAPtr^[n]:=x; in which n>650 will not be trapped by the compiler at run-time and will |
Mike Copelan
![]() Delphi Developer |
Thu, 10 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuote> > There is some inherent risk in turn off range Checking if you use a "maximum" array, the programmer _must_ do virtual range checking within the application code. In all cases where this idea of "dynamic arrays" is used, the programmer must be extra careful, and there's always some risk involved... |
John R. Reag
![]() Delphi Developer |
Fri, 11 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuoteIn article <4qbh5e$...@client3.news.psi.net>, l...@lutz.com writes... The construct asked for is perfectly legal. -- |
Voti
![]() Delphi Developer |
Fri, 11 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeHi all, Joining the discussion about dynamic array allocation, where many Of course, the elements stored in a TCollection must be descendants of some I believe anyone who is in a project that serious, to demand dynamic array Greetings, --------------------------------------------------------------------------- |
Jason Burgo
![]() Delphi Developer |
Sat, 12 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeIn article: <1996Jun24.171609.1...@arl.mil> Votis Quote<paratiritis.the.forthnet...@forthnet.gr> writes: any of BP's three target platforms). Quote> which actually *is* a dynamically example. Quote> and they may be polymorphic, i.e. of different types, as they have at their elbow. -- Jay --------------------------------------------------------------------------- |
Jacques Gu
![]() Delphi Developer |
Thu, 17 Dec 1998 03:00:00 GMT
Re:Dynamic Array SizeQuoteMike Copeland wrote: an object along these lines: aNullArray=array[0..0] of byte; I object to having to do that. All that should be taken care of by |
1. [Fwd: Re: Dynamic Array Size (2)]
4. Tips on dynamic arrays, and help with dynamic arrays of records
5. dynamic allocate the size of an array ?
6. Dynamic size arrays using pointers 2/2
7. dynamic sized array of TBitmap
8. dynamic memory allocation and dynamic arrays-Help