Board index » delphi » How to declare an array constant?

How to declare an array constant?

Hi,

A simple question: How do you declare a constant array?

Thanks.

Francis

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
= The opinions expressed here do not reflect those of my employer.  =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=     Francis Chang               fran...@patch.tandem.com          =
=     Tandem Computers Inc.       (408)285-6863  Phone              =
=     NonStop SQL Development     (408)285-2227  FAX                =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

 

Re:How to declare an array constant?


Quote
Francis E. Chang wrote:

> Hi,

> A simple question: How do you declare a constant array?

> Thanks.

> Francis
> try this:

const
 months : array [1..12] of string[3]=
    ('Jan', 'Feb', 'Mar', 'Apr',
     'May', 'Jun', 'Jul', 'Aug',
     'Sep', 'Oct', 'Nov', 'Dec') ;

--
My opinions are my own and do not in any way reflect
those of my employer.
-

Re:How to declare an array constant?


fran...@patch.tandem.com (Francis E. Chang) wrote:

Quote
>Hi,
>A simple question: How do you declare a constant array?
>Thanks.
>Francis

 Here is couple simple examples:

 type
   TMyRec = record
     first:  byte;
     second: String[10];
     third: String[15];
   end;

 const
   MYSTR = Array[1..3] of String[10] = ('Declaring','constant','array');
   MYREC = Array[1..3,1..2] of TMyRec = (
     ((first: 1,second: 'A',third: 'B'),(first: 2,second: 'C',third: 'D')),
     ((first: 3,second: 'E',third: 'F'),(first: 4,second: 'G',third: 'H')),
     ((first: 5,second: 'I',third: 'J'),(first: 6,second: 'K',third: 'L'))
   );

---
  Matti Kohtala
  mkoht...@ratol.fi

Re:How to declare an array constant?


Quote
Francis E. Chang wrote:

> Hi,

> A simple question: How do you declare a constant array?

> Thanks.

> Francis

I think you mean this:

const
  AnArrayConst : Array[1..9,1..10] Of Byte =
   ((8,8,8,8,8,8,8,8,8,8),
    (7,7,7,7,7,7,7,7,7,7),
    (5,5,5,5,5,5,5,5,5,5),
    (5,5,5,5,5,5,5,5,5,5),
    (4,4,4,4,4,4,4,4,4,4),
    (3,3,3,3,3,3,3,3,3,3),
    (0,0,0,0,0,0,0,0,0,0),
    (0,0,0,0,0,0,0,0,0,0),
    (0,0,0,0,0,0,0,0,0,0));

Jaap Mosselman
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Research Station for Cattle, Sheep and Horse Husbandry (PR)
Runderweg 6          8219 PK Lelystad       The Netherlands
E-mail: J.Mossel...@pr.agro.nl   Fax nr: +31 (0)320 241 584

Other Threads