TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: HS
date: 1997-05-02 00:49:00
subject: Why(?!) does it not work???

From: HS 
Hi
I'm still working on a macro that should re-format a given text within my
prefered margins.
One thing it should do is, to insert a blank line between two paragraphs
when there is not already one; that is, when the text looks like this
(hopefully it will not get reformated on the way to you):
 abcdefghijklmnopqrstuvwxyz
 abcdefghijkl.
 abcdefghijklmnopqrstuvwxyz
 abcdefg!
 abcdefghijklmnopqrstuvwxyz
 abcdefghijklmnopqrstuvwxyz
 abcdefghijklmnopqrs?
The macro should change this to:
 abcdefghijklmnopqrstuvwxyz
 abcdefghijkl.
 abcdefghijklmnopqrstuvwxyz
 abcdefg!
 abcdefghijklmnopqrstuvwxyz
 abcdefghijklmnopqrstuvwxyz
 abcdefghijklmnopqrs?
This is my macro file (it assummes that the paragraph ends with a line that
is a certain nubmer of characters shorter than the longest line in the text
and ends with a . ! ? or such.):
/* Reform reformatiert einen Text zwischen den Randern 0 und 76
 */
/* LongestLine looks for the length of the longest line */
integer proc LongestLine()
   integer last_line,
           max_len = 0
        BegFile()
        last_line = NumLines()
        max_len = CurrLineLen()
    while Down() and (CurrLine() <= last_line)
        if CurrLineLen() > max_len
            max_len = CurrLineLen()
        endif
    endwhile
    return (max_len)
end LongestLine
/* InsertBlankLine inserts a blank line after a paragraph in a given text
which does not already end with a blank line. A paragraph end is recognized
in this case by a significant shorter line than the longest line in the file
and ends with a possible paragraph end character */
     integer epl = 0,  // counts End Paragraph Line
             lf = 0, // results of lFind
             nbl  = 0 // counts non-blank lines after paragraph
proc InsertBlankLine()
    BegFile()
    While lFind("[!.?"]$", "x") and Down()
        lf = (lf + 1)
        if CurrLineLen() < (LongestLine() -14)
        epl = (epl + 1)
            Down()
            if CurrLineLen()  0
                nbl = (nbl + 1)
                BegLine()
                SplitLine()
                Down()
            endif
        endif
    endwhile
end // InsertBlankLine
proc main()
    longestline()
    InsertBlankLine()
message("Longest line: ", longestline(), "; foundd: ", lf, ";
    EndParaLines: ", epl, "; NonBlankLines: ", nbl)
end
These counters and message() are only to show that something happens. It
finds the longest line (ok I know it is  stolen from the TSE
"Longestline.s".).
It finds ONLY ONE OCCURENCE with one endparaline although there are hundrets
in my test text.
And it does NOT insert a blank line.
It does NOT hang and toes through the whole file.
Thanks for any help.
Hanspeter Schaffner
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.