[Oberon] Re (3): Search in Text, was "Detecting whether a Text is a module source."
lab.eas at gmail.com
Thu Feb 2 03:39:30 CET 2017
Andreas Pirklbauer wrote:-
]> Procedure Search in module Edit.Mod ... Boyer-Moore
]> search algorithm.
] I might succeed to revise Edit.Search with result such as this.
] PROCEDURE Search*(T: Texts.Text; VAR pos: LONGINT; pattern: ARRAY OF CHAR);
Consider how you do it manually:
1= klik Filename = cat Filename
2= wipe string = string
3= klik SearchButton = grep
Let's *LEARN* from the massive productivity increase of *nix!
which just automates our ETHO manual steps [not using minimal syntax] :-
` cat Filename | grep string ` <- 2-stage pipe
And importantly the 2 pipeSections can be indepenently reused for eg.
`cat /home/Softwr/LEOmenu/ET.Mod | grep PROC | wc -l ` == 1
I don't believe it! OK, it's because of CR/LF: ET.Mod is one line
for linux; and grep returns THE line/S containing "PROC".
So let's first translate OberonToUnix before grep:
`cat /home/Softwr/LEOmenu/ET.Mod | o2u | grep PROC | wc -l ` == 101
That seems like too much? let's look at the 7'th last one:
`cat /home/Softwr/LEOmenu/ET.Mod | grep PROC |tail -7|head -1 ` ==
Binary file (standard input) matches
OK, you want to be difficult: saying that it exists, but you can't
show the non-ASCII text?
`cat /home/Softwr/LEOmenu/ET.Mod | strings | grep PROC |tail -7|head -1`
` cat /home/Softwr/LEOmenu/ET.Mod | o2u | grep PROC |tail -7|head -1 `
`o2u` is my own little one-line-script: translating ETHO's EOL to *nix's
Remember ET.Mod had a non-ASCII header.
AFAIK it's Andreas Pirklbauer who had made a <Full Oberon functional
system>; but he's used the disasterous M$ notation of using multiple
tokens to represent a SingleEntity ! eg:-
instead of "47"
Let's use all the good stuff of ETHO and make a facility to use
BTW I'm writing/while testing the code; using wily,
which is a good example of learnig and extending what ETHO already
had proven. With LinuxEthOberon, I could have had it in colour! eg.
cat /home/Softwr/LEOmenu/ET.Mod | strings | grep PROC |tail -7|head -1
I can't test/confirm that now, since which my existing system,
LEO only runs under DebianDVDrescueGraphic mode.
== Chris Glur.
More information about the Oberon