[Oberon] Need V4 Code for trivial task.

Douglas G Danforth danforth at greenwoodfarm.com
Mon Nov 28 09:58:58 CET 2016


Chris,
This V4 code seems to work!
Needing to cast a BYTE using ORD threw me for a while.  You don't need to do
that with Component Pascal.

MODULE Foo;

     IMPORT
         Files,
         SYSTEM;

     VAR
         rd:    Files.Rider;
         wr:    Files.Rider;
         inFile:    Files.File;
         outFile:    Files.File;

     PROCEDURE Open* (out, in: ARRAY OF CHAR): BOOLEAN;
     VAR flag: BOOLEAN;
     BEGIN
         inFile := Files.Old(in);
         flag := (inFile # NIL);
         IF flag THEN
             Files.Set(rd, inFile, 0);
             outFile := Files.New(out);
             flag := (outFile # NIL);
             IF flag THEN
                 Files.Set(wr, outFile, 0)
             END
         END;
         RETURN flag
     END Open;

     PROCEDURE Strip* ;
     VAR b: SYSTEM.BYTE;
     BEGIN
         Files.Read(rd, b);
         WHILE ~rd.eof DO
             IF (ORD(b) = 13) OR (ORD(b) = 10) THEN b := 32 END;
             Files.Write(wr, b);
             Files.Read(rd, b);
         END;
         Files.Register(outFile);
         Files.Close(inFile)
     END Strip;

     PROCEDURE Test*;
     BEGIN
         IF Open("TestOut.Mod", "TestIn.Mod") THEN Strip END;
     END Test;

END Foo.Test   << middle mouse click there to run the program

TestIn.Mod looks like
This is a
sentence with lots
of line breaks.
Hope this
works!

TestOut.Mod looks like
This is a sentence with lots of line breaks. Hope this works!

-Doug
On 11/27/2016 10:40 PM, eas lab wrote:
> 2 apparently independant Windows bases TextToSpeech translator, both
> absurdly pause at the text's <newlines>, making the speech sound bad.
>
> Linux fixes that with:--
> # remove all EOL :  \n = new line; \r = return
> #tr -d \n | tr -d \r \NNN :Octal 10+2=> 012; 13=8+5=>015; 32=\040
>
> cat $1 | tr -d "\012" | tr -d "\015" | \
> sed 's/\./\.\r\n/g' | sed 's/  / /g' >> $2
> # CrLf after each period & double-space to single-space <-irrelevant
>
> But I currently can't get inet except via M$, and I can't afford
> to switch to *nix for trivial tasks which I can't do with M$!!
>
> Since Oberon V4 is running in M$, I thought of:
>
> OpenInfile; OpenOutfile;
> FOR Char:=NextByte(Infile)
>    IF (Ord(Char) = 10) OR (Ord(Char) = 13)
>    THEN Write(Outfile, Ord(32)
>    ELSE Write(Outfile, Char END;
> CloseInfile; CloseOutfile.
>
> You can see that I'm no longer fluent/familiar with <Algol> ?!
>
> My ETHO documentation is lost/destroyed, and it's pointless to
> collect replacements it [since I need to stay dependent on a M$
> laptop, to easily flee as the 'revolution' progresses];
> but I remember that per S3 documentation:
> opening & closing files involved <riders>.
>
>
> Can someone please sketch some V4 syntax to solve this problem,
> since I've really only installed V4 for the <ability to access
> multiple text files together on the same screen>; which apparently
> is beyond the imagination of the M$ designers.
>
> Thanks,
>
> == Chris Glur.
>
> PS. I looked at M$'s good idea to follow *nix's shell idea,
> but you can see that M$'s founder has lawer ancestors: who have
> the lawer's moto "if ten thousand words will do, why use ten".
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>

-- 
Danforth of the Greenwood

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20161128/968eea87/attachment.html>


More information about the Oberon mailing list