Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-03

Pascal arrays vs TStringList.DelimitedText

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Francisco Reyes

Getting back to Pascal.. Aren't pascal arrays 1 based?

As I get myself re-acquainted with pascal I am working on a small open source utility. Bumped into something that confused me.. It seems TStringList.DelimitedText produces an array that starts at zero, but from what I can tell regular arrays there a list anywhere of which classes in the FCL use arrays that start at zero?

Tried reading the Tstringlist documentation and the beginning of the classes unit for any indicator of arrays in that unit starting at zero, but did not see any. Did I miss it?

Reply by email

Paul Nicholls
to Francisco Reyes

----- Original Message -----

Earlier message 39 lines
From: "Francisco Reyes" To: "FreePascal list" Sent: Friday, March 20, 2009 2:32 PM Subject: [fpc-pascal] Pascal arrays vs TStringList.DelimitedText > Getting back to Pascal.. Aren't pascal arrays 1 based? > > As I get myself re-acquainted with pascal I am working on a small open > source utility. Bumped into something that confused me.. It seems > TStringList.DelimitedText produces an array that starts at zero, but from > what I can tell regular arrays start at 1. > > > Is there a list anywhere of which classes in the FCL use arrays that start > at zero? > > Tried reading the Tstringlist documentation and the beginning of the > classes unit for any indicator of arrays in that unit starting at zero, > but did not see any. Did I miss it? Hi Francisco, regular arrays can start at whatever index you want: Var MyArray1 : Array[1..3] Of Integer; MyArray2 : Array[-3..21] Of String; Dynamic Arrays : Var MyDynamicArray : Array Of Integer; These always start with a zero index. TStringList and similar classes use a zero index too. I don't know if there is any list like you want though... cheers, Paul

Reply by email

Francisco Reyes
to Paul Nicholls
Paul Nicholls wrote
Hi Francisco, regular arrays can start at whatever index you want: Var MyArray1 : Array[1..3] Of Integer;

Thanks for the info and examples.

Dynamic Arrays : MyDynamicArray : Array Of Integer;

..

These always start with a zero index.

This is very usefull too.
I will check when I use a class for the first time. I guess most will start at zero then since the classes probably use dynamic arrays.

Reply by email