Am 27.04.2020 um 13:46 schrieb Seymour J Metz:
But can you use a character as an initial or limit value in a DO? That's
possible in some other languages.
yes:
for ch := 'A' to 'Z' do
writeln ('character with ord = ', ord (ch), ' appeared ', howoften
[ch]);
I did not use this in the example below, because I wanted to cover the
complete range of char
and both CHR (0) and CHR (255) are not printable characters.
The coding above is not really portable, because in ASCII there are 26
chars between 'A' and 'Z',
but in EBCDIC, there are more :-)
BTW: I extended Stanford Pascal long ago to support hexadecimal
notation, so I could code
my original example as:
for ch := X'00' to X'FF' do
writeln ('character with ord = ', ord (ch), ' appeared ', howoften
[ch]);
without the need for the conversion functions.
There again, I had to take care of the incompatibiliy between char and
integer types:
X'FF' is a char hexadezimal constant
0xFF is an integer hexadezimal constant
http://bernd-oppolzer.de/job9i029.htm
Kind regards
Bernd
--
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
--
Oppolzer-Informatik
Dipl. Inf. Bernd Oppolzer
Bärenhofstraße 23
70771 Leinfelden-Echterdingen
—————————————————————
Tel.: +49 711 7949591
priv.: +49 711 7949590
mobil: +49 151 75005359
eMail: [email protected] <mailto:[email protected]>
Web: http://bernd-oppolzer.de/job.htm
—————————————————————
Für Umsatzsteuerzwecke:
SteuerNr.: 97 076 / 29921
USt-ID-Nr.: DE 147 700 393
—————————————————————
Oppolzer-Informatik 1983 - 2019
36years of experience in computer science**
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN