Board index » delphi » Open arrays - can it be done?

Open arrays - can it be done?

Quote
Yu Kwan Cheng wrote:
>Mr. Muzzi the way I learned it is this way.  And I use it a lot in my
>current projects.

>type  
>   somearray = array[0..0] of char;
>   someptr     = ^somearray;
>var
>   somearrayptr : someptr;
>begin
>    getmem(somearrayptr, somesize);
>end.

>Is this correct?

This is correct and often done.

However, the following generates a compilation error because the 2 is out of
range:

    somearray^[2] := value;

This may not be a problem and is easily remedied by using a variable instead
of a constant in the array index.

Ron Muzzi, EE
Great Lakes Environmental Research Lab
Ann Arbor, Michigan, USA
rmu...@glerl.noaa.gov

 

Re:Open arrays - can it be done?


On Mar 06, 1996 11:41:46, 'rmu...@glerl.noaa.gov (Ron Muzzi)' wrote:

Quote
>Yu Kwan Cheng wrote:

>>Mr. Muzzi the way I learned it is this way.  And I use it a lot in my
>>current projects.  

>>type  
>>   somearray = array[0..0] of char;  
>>   someptr     = ^somearray;  
>>var  
>>   somearrayptr : someptr;  
>>begin  
>>    getmem(somearrayptr, somesize);  
>>end.  

>>Is this correct?  

>This is correct and often done.

>However, the following generates a compilation error because the 2 is out
of  
>range:

>somearray^[2] := value;

>This may not be a problem and is easily remedied by using a variable
instead  
>of a constant in the array index.

>Ron Muzzi, EE
>Great Lakes Environmental Research Lab
>Ann Arbor, Michigan, USA
>rmu...@glerl.noaa.gov

Thanks!  

- Show quoted text -

Quote

Other Threads