943,929 Members | Top Members by Rank

Ad:
Dec 19th, 2007
0

List vector

Expand Post »
How do I list the number of elements in a vector, i.e test : array[1..10] of string; ?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
spockenheit is offline Offline
3 posts
since Nov 2007
Dec 19th, 2007
0

Re: List vector

I think it's something like this
Delphi Syntax (Toggle Plain Text)
  1.  
  2. program ??;
  3.  
  4. var test : array[0..4] of String;
  5. l : Integer;
  6.  
  7.  
  8. begin
  9.  
  10. a[0] := '1';
  11. a[1] := '2';
  12. a[2] := '3';
  13. a[3] := '4';
  14. a[4] := '5';
  15.  
  16.  
  17. writeLn('There are ',length(a),' elements in the array');
  18.  
  19. end.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Artmann is offline Offline
19 posts
since Nov 2007
Dec 19th, 2007
0

Re: List vector

length() returns the number of elements in an array.
low() returns the index of the first element.
high() returns the index of the last element.
setLength() changes the size of a dynamic array.
Delphi Syntax (Toggle Plain Text)
  1. var
  2. xs: array of integer;
  3. cntr: integer;
  4. begin
  5. setLength( xs, 5 );
  6. writeln( 'Please enter ', length( xs ), ' integers: ' );
  7. for cntr := low( xs ) to high( xs ) do read( xs[ cntr ] );
  8. end.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: how to load a word documnet into a twebbrowser...
Next Thread in Pascal and Delphi Forum Timeline: A problem in my bar image to control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC