<div style='font-family:arial; font-size:13px;'><div>Hi Jorg,</div><div><br></div><div>Thanks for the reply. That's a neat solution. I can do that with the string library provided in OBNC. I was wondering how to do it with a CASE statement but it seems quite limited without ELSE. ie, for this example you would have to explicitly list all the values which ch could take (other than vowels). I learned (Turbo) pascal years ago and have recently started programming again. I never really liked the C syntax languages and rather than use Free Pascal I thought I'd give Oberon a try. I wonder if Wirth took minimalism a bit too far in this version though?<br></div><br><div link="#0563C1" vlink="#954F72" style="word-wrap:break-word" lang="DE-CH">January 24, 2022 4:03:08 PM CET "Jörg" <joerg.straube@iaeth.ch> wrote:<blockquote type="cite" cite="<AA27366E-027D-41E6-8AF8-3E85FFD0B408@iaeth.ch>"><div class=""><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">Hi Joe<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">LOOP/EXIT might seem handy, but for source code readability and maintainability reasons it was neglected.<br>Use REPEAT or WHILE instead.<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">If numeric case is not implemented, use IF ELSIF or IF OR instead<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">Or look into this “elegant” alternative </span><span style="font-family:"Apple Color Emoji";mso-fareast-language:EN-US" lang="EN-US">😊</span><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> IMPORT In, Out, Strings;<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> …<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> In.Char(ch);<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> WHILE In.Done DO<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> Strings.Search(ch, “AEIOUaeiou”, pos); IF pos >= 0 THEN INC(countVowels) END;<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> In.Char(ch)<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"> END;<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">The Module Strings.Mod is quite portable.<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">I can send you the Oberon-07 version of it if you don’t have it.<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">br<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US">Jörg<o:p></o:p></span></p><p class=""><span style="mso-fareast-language:EN-US" lang="EN-US"><o:p> </o:p></span></p><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class=""><b><span style="font-size:12.0pt;color:black">Von: </span></b><span style="font-size:12.0pt;color:black">Oberon <oberon-bounces@lists.inf.ethz.ch> im Auftrag von Joe Turner <medianjoe@mailfence.com><br><b>Antworten an: </b>ETH Oberon and related systems <oberon@lists.inf.ethz.ch><br><b>Datum: </b>Montag, 24. Januar 2022 um 15:15<br><b>An: </b><oberon@lists.inf.ethz.ch><br><b>Betreff: </b>[Oberon] How to write this program in Oberon-07?<o:p></o:p></span></p></div><div><p class=""><o:p> </o:p></p></div><div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">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):<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">MODULE case;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">IMPORT In,Out;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">VAR countVowels: INTEGER; ch: CHAR;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">BEGIN<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> In.Open;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> countVowels:=0;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> LOOP<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> In.Char(ch);<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> IF ~In.Done THEN EXIT END;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> CASE ch OF<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> "a", "e", "i", "o", "u",<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> "A", "E","I","O","U": INC(countVowels)<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> ELSE<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> END;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> END;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> Out.Int(countVowels,0);<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> Out.String(" vowels read.");Out.Ln;<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">END case.<o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Oberon-07 doesn't allow LOOP, EXIT, or ELSE in CASE. <o:p></o:p></span></p></div><div><p class=""><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Thanks in advance for any help.<o:p></o:p></span></p></div></div><p class="">-- Sent with https://mailfence.com Secure and private email -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon <o:p></o:p></p></div>
<pre style="font-size:13px;">--<br>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems<br><a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><br></pre></blockquote></div></div>
--
Sent with https://mailfence.com
Secure and private email