Arif Ikhsanudin
Arif Ikhsanudin

Reputation: 804

How to make a multi line array in pascal

I made a basic array like as shown below. Can I make array per line? without double quotes and commas?

 var
  Month: array [1 .. 5] of string = ('January', 'February', 'March', 'April', 'May');
begin
  Write(Month[4]);
  Readln;
end. 

That might be like this

Month: array [1 .. 5] of string = (
January
February
March
April
May
)

begin
  Write(Month[4]);
  Readln;
end.

regards.

Upvotes: 1

Views: 374

Answers (1)

Rudy Velthuis
Rudy Velthuis

Reputation: 28806

No, what you want is not possible. The syntax doesn't allow it.

You can do the following:

const
  Month: array[1..5] of string = (
    'January',
    'February', 
    'March', 
    'April',
    'May'
  );

But not what you want. Line endings (or any other whitespace) are not proper separators, and strings must always be enclosed in single quotes, and array elements (of a const array) must separated by commas.

Upvotes: 2

Related Questions