Am 27.04.2020 um 05:56 schrieb Paul Gilmartin:
On Mon, 27 Apr 2020 04:23:49 +0200, Bernd Oppolzer wrote:

On the other hand, Pascal supports ANY standard or scalar or subrange
type as index type
for arrays, for example:

var howoften : array [char] of integer ;
    ch: char;
...
read (ch);
howoften [ch] := howoften [ch]  + 1;

the array howoften is used to count the occurence of chars in an input
file, for example.

But can you use a char as a control variable of DO to
step through the howoften array?

yes:

for ch := chr (0) to chr (255) do
   writeln ('character with ord = ', ord (ch), ' appeared ', howoften [ch]);

I used ord here because not all chars are printable ...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to