I have modified your code, now it works fine..
 
procedure TForm1.Button1Click(Sender: TObject);
Var
StrArray : Array of String;
I :integer;
begin
    SetLength(StrArray,20);
    Try
      For I := 0 to 19 do
       begin
         {Popoulate array}
         Strarray[I]:= IntToStr(I) + 'Data';
         {Show what has been populated}
         Showmessage(StrArray[I]);
       end;
    Finally
      {Clear array and set to zero}
      SetLength(StrArray, 0);
    end;
end;


"Nesler, Thomas J" <[EMAIL PROTECTED]> wrote:
Hello!

I am using Delphi 5.  I need to work with Dynamic arrays.  Reading in
the help file it says that:

'Once a Dynamic array has been allocated, you can pass it to the
standard functions Length, High and Low.  Length returns the number of
elements in the array, ...'

I can't seem to get this to work.  When I try to compile I get this
error:

'[Error] Unit1.pas(34): Record, object or class type required'

Here is some sample code I used to try to figure out how to work with
dynamic arrays:

procedure TForm1.Button1Click(Sender: TObject);
Var
StrArray : Array of String;
I :integer;
begin
    SetLength(StrArray,20);
    For I := 0 to 19 do Strarray[I]:= IntToStr(I) + 'Data';
    label1.Caption := IntToStr(Strarray.length);    <-----Error here
end;

************  End of code *****************

What am I doing wrong?  I realize this code is contrived but I should be
able to derive what the size of an array is via this method, right?

Thanks in advance!

Tom Nesler
Live long!...   Code Well!...   and Prosper!...   V



[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 



SPONSORED LINKS 
C programming language Computer programming languages The c programming 
language C programming language List of programming languages Delphi programmer 

---------------------------------
YAHOO! GROUPS LINKS 


    Visit your group "delphi-en" on the web.
  
    To unsubscribe from this group, send an email to:
 [EMAIL PROTECTED]
  
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


---------------------------------



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h4253mt/M=362131.6882499.7825260.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1123536727/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

-----------------------------------------------------
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/
 



Reply via email to