[Oberon] How to write this program in Oberon-07?
medianjoe at mailfence.com
Mon Jan 24 20:04:48 CET 2022
August, thanks for that. Are you by any chance the author of OBNC? Not that I'm an expert - far from it, but it's a very nice compiler and easy to use.
I never learned OOP with Turbo Pascal and have been avoiding it for a long time because the terminology put me off - classes, methods, polymorphism, inheritance etc. One of the things which attracted me to Oberon is the way OOP is handled; it's just an extension of the record concept, so I'm looking forward to learning it at last. Good to know you experts are on hand to help me out if I get stuck!
Thanks again to you and Jorg for the words of wisdom.
January 24, 2022 7:29:53 PM CET August Karlstrom <fusionfile at gmail.com> wrote:As mentioned by Jörg, Oberon-07 is a pure structured language in the
sense that each (ASSERT free) statement sequence is either fully
executed or not executed. With CASE statements you can often limit the
range of values to inspect before the CASE statement is executed. Here
is one way to do it:
IMPORT In, Out;
ch, capCh: CHAR;
countVowels := 0;
WHILE In.Done DO
IF (ch >= "a") & (ch <= "z") THEN
capCh := CHR(ORD("A") + ORD(ch) - ORD("a"))
capCh := ch
IF (capCh >= "A") & (capCh <= "U") THEN
CASE capCh OF
"B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q",
"R", "S", "T":
Out.String(" vowels read.");
With the WHILE loop we can see instantly that it will continue until
there are no more characters to read. Compare this to the LOOP in which
the exit condition (or possibly exit conditions) is buried in the
contained statement sequence.
On 2022-01-24 15:14, Joe Turner wrote:
> I'm working through the book "Into the Realm of Oberon" which is written
> for Oberon-2. I can't figure out how to translate the following program
> into Oberon-07 (I'm using the OBNC compiler):
> MODULE case;
> IMPORT In,Out;
> VAR countVowels: INTEGER; ch: CHAR;
> IF ~In.Done THEN EXIT END;
> CASE ch OF
> "a", "e", "i", "o", "u",
> "A", "E","I","O","U": INC(countVowels)
> Out.String(" vowels read.");Out.Ln;
> END case.
> Oberon-07 doesn't allow LOOP, EXIT, or ELSE in CASE.
> Thanks in advance for any help.
> -- Sent with https://mailfence.com Secure and private email
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
-- Sent with https://mailfence.com Secure and private email
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Oberon