[Oberon] Need V4 Code for trivial task.

Chris Burrows chris at cfbsoftware.com
Mon Nov 28 11:33:20 CET 2016


Hi Doug,

You don't need to use any SYSTEM facilities or casts in Oberon for this
task. 

Replace:

  VAR b: SYSTEM.BYTE;

with:

  VAR ch: CHAR;

Then you can say:

  IF (ch = 0AX) OR (ch = 0DX) THEN ch := " " END;

Regards,
Chris

Chris Burrows
CFB Software
http://www.astrobe.com


From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Douglas
G Danforth
Sent: Monday, 28 November 2016 7:29 PM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Need V4 Code for trivial task.

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



More information about the Oberon mailing list