But can you use a character as an initial or limit value in a DO? That's 
possible in some other languages.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of 
Bernd Oppolzer [[email protected]]
Sent: Monday, April 27, 2020 3:45 AM
To: [email protected]
Subject: Re: XL C\C ++ sizeof of datatypes

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

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

Reply via email to