' CONVLNK(2.4)  Conv Plain Text Link List into HTML    02/11/2003-07/21/2005
' --------------------------------------------------------------------------
' Copyright (C) 2003-2005 by Vladimir Veytsel                  www.davar.net

' Type ---------------------------------------------------------------------

'    Procedure

' Parameters (up to 2 Optional Separated by "," or " ") --------------------

'    1. Name of the links TXT/HTM file (Deflt: LINKS in the CURRENT direct)

'    2. Replacement specification (Default: No replacements)
'       Form:  &lt;Key_1>-&lt;Val_1>/&lt;Key_2>-&lt;Val_2>/&lt;Key_3>-&lt;Val_3>...
'       E.g.:  INT-E/INF-H
'       ("-" is used instead of "=" to simplify setting it via environment)
'       Up to 10 replacements may be specified as the second parameter.
'       Replacement might be necessary only for conversion of personal
'       links that are used instead on Netscape's "Personal Toolbar".
'       They provide the mechanism to specify local drives for the local
'       links, so that the same *.TXT personal links file could be adjusted
'       to the specific computer at the time of links' conversion.

' TXT Links File Format ----------------------------------------------------

'  - First line is always a title, last 10 positions of which represent
'    link list modification date to be inserted into the &lt;name>.HTM file
'    first and second lines.  Title should be delimited from dates by
'    at least TWO spaces.  Year is inserted in the right part of the
'    Copyright range if one is found.

'  - Any blank lines are ignored (serve as convenient vertical visual
'    delimiter) - link formatting is controlled by the indentation only.

'  - Any lines starting with "*" (which might be preceded by spaces)
'    are ignored.  This permits to imbed any comments within &lt;name>.TXT
'    links file as well as to comment out certain lines.

'  - Line consisting of all "=" terminates reading of plain text links
'    file.  This permits to keep any links yet to be verified below
'    this EOF line.

'  - If replacement is specified, every *.TXT line is checked for the
'    presence of every specified %&lt;Key_x>%, and, if found, it gets
'    replaced by the corresponding value.  This permits to tune personal
'    links during conversion (substitute for "personal toolbar") according
'    to the specific computer where it has to be used.
'    E.g.:  Manual (vendor manuals) | file:///%INF%:/Manual/HTM
'    The "Manual" directory is located on different drives for different
'    computers of the group, and using %INF% parameter in *.TXT permits
'    to replace it with the proper drive letter at the time of conversion
'    (conversion batch script has to take care of that).

'  - Unindented lines are section headers in the form of:
'    &lt;text> [(&lt;comment>)] [| &lt;URL>]
'    &lt;text> represents the name of the section (preferably short, since
'           it goes into top and bottom internal navigation bars),
'    &lt;comment> is optional (might be useful to explain short section name),
'    &lt;URL> is optional and, if used, provides the link to the related
'          section of the same web site (directory structure), where
'          the &lt;name>.HTM links page is located.

'  - Indented lines (indent size is irrelevant - at least one blank
'    is sufficient) are links in the form of:
'    &lt;text> [(&lt;comment>)] | &lt;URL>
'    &lt;text> represents the name of the link,
'    &lt;comment> is optional,
'    &lt;URL> provides link to the named page.

'  - The most obvious way to specify the URL is to specify it complete
'    with the protocol, i.e., "http://www.davar.net", not "www.davar.net".
'    However, it's obvious that close to 100% of all URLs will always
'    start with "http://", and it's pointless and wasteful to specify it
'    each time.  Exceptions, though negligible in volume, are still very
'    important, so, while assuming the "http://" as a default, the following
'    rules are used to handle the exceptions:

'    - If URL starts with the "_" (protocol is not necessary),
'         then "_" is trimmed away and the rest of URL is taken as is -
'              this covers rare, but vital case when it refers to the
'              page within the same directory structure.
'    - If URL contains "://" within the first 8 characters
'         (protocol is specified explicitly),
'         then URL is taken as is - this covers the cases when either
'              "http://" is already specified (e.g.: got there by
'              cut-and-paste), or another protocol is necessary for
'              this link, e.g.: "https://", or "ftp://", or "file:///"
'    - If none of the above conditions is met (protocol is defaulted),
'         then "http://" is inserted in front of specified URL.

'    Note:  The above doesn't apply to section links - they are needed only
'           for cross-references (if any) within the same web site (directory
'           structure), and for this reason are always taken as is.

'  - E.g.:

'    Client / Server Links  (DAVAR\CS\LINKS.TXT)  09/27/2001-08/29/2002

'    Reference | REFER/REFER.HTM

'     On-Line Dictionary of Computing | wombat.doc.ic.ac.uk/foldoc
'     Dictionary of PC Hardware and Data Communication Terms | www.oreilly...

'    UNIX

'     UNIX References (HTML and PDF, University of Northern Carolina) | help...
'     UNIX Commands (University of Central Florida) | www.acs.ucf.edu/man...

' HTM Links File Format ----------------------------------------------------

'  - HTML prologue of the &lt;name>.HTM links page that is finished by the line
'    "&lt;!-- Links Start -->" (possibly padded with blanks on on both or any
'    side).  Indent of this line (if any) is used as the BASE indent for
'    all converted links.

'  - List of links to be substituted by the newly generated from &lt;name>.TXT
'    file.  Note: There is no &lt;HR> before the FIRST section.

'  - E.g.:

'    &lt;CENTER>&lt;FONT SIZE=4 COLOR=Red>&lt;B>&lt;U>Client / Server&nbsp; Links&lt;/U>&lt;/B>&lt;/FONT>&lt;/CENTER>
'    &lt;BR>&lt;!--------------------------------------------------------------->
'        &lt;A NAME="Reference">&lt;/A>
'        &lt;TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
'          &lt;TR>
'            &lt;TD>&nbsp;&lt;A HREF="REFER/REFER.HTM">&lt;I>&lt;B>Reference&lt;/B>&lt;/I>&lt;/A>&lt;/TD>
'            &lt;TD ALIGN=Right>
'              &lt;I>
'                &lt;FONT COLOR=Green>Go to:&lt;/FONT>&nbsp;
'                                          &lt;A HREF="#UNIX">Next sect&lt;/A>
'                &lt;FONT COLOR=Green>|&lt;/FONT>
'                                          &lt;A HREF="#Bottom">List bot&lt;/A>&nbsp;
'              &lt;/I>
'            &lt;/TD>
'          &lt;/TR>
'        &lt;/TABLE>
'        &nbsp; &nbsp; &nbsp;
'        &lt;A HREF="http://wombat.doc.ic.ac.uk/foldoc/index.html">
'           On-Line Dictionary of Computing&lt;/A>
'    &lt;BR>&nbsp; &nbsp; &nbsp;
'        &lt;A HREF="http://www.oreilly.com/reference/dictionary/">
'           Dictionary of PC Hardware and Data Communication Terms&lt;/A>
'    &lt;HR>&lt;!--------------------------------------------------------------->
'        &lt;A NAME="UNIX">&lt;/A>
'        &lt;TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
'          &lt;TR>
'            &lt;TD>&nbsp;&lt;FONT COLOR=Navy>&lt;I>&lt;B>UNIX&lt;/B>&lt;/I>&lt;/FONT>&lt;/TD>
'            &lt;TD ALIGN=Right>
'              &lt;I>
'                &lt;FONT COLOR=Green>Go to:&lt;/FONT>&nbsp;
'                                          &lt;A HREF="#Top">List top&lt;/A>
'                &lt;FONT COLOR=Green>|&lt;/FONT>
'                                          &lt;A HREF="#Reference">Prev sect&lt;/A>
'                &lt;FONT COLOR=Green>|&lt;/FONT>
'                                          &lt;A HREF="#Solaris">Next sect&lt;/A>
'                &lt;FONT COLOR=Green>|&lt;/FONT>
'                                          &lt;A HREF="#Bottom">List bot&lt;/A>&nbsp;
'              &lt;/I>
'            &lt;/TD>
'          &lt;/TR>
'        &lt;/TABLE>
'        &nbsp; &nbsp; &nbsp;
'        &lt;A HREF="http://help.unc.edu/index.xsp?id=1603&trail=1146,1603&sort=score&">
'           UNIX References&lt;/A>&nbsp; (University of Northern Carolina – HTML and PDF)
'    &lt;BR>&nbsp; &nbsp; &nbsp;
'        &lt;A HREF="http://www.acs.ucf.edu/manuals/unix/commands.html">
'           UNIX Commands&lt;/A>&nbsp; (University of Central Florida)
'    &lt;BR>&nbsp; &nbsp; &nbsp;
'        &lt;A HREF="http://www.acs.ucf.edu/manuals/unix/email.html">
'           E-Mail&lt;/A>&nbsp; (University of Central Florida)

'  - HTML epilogue of the &lt;name>.HTM links page that is started by the line
'    "&lt;!-- Links Finish -->".

' Action -------------------------------------------------------------------

'  - Reads &lt;name>.TXT file and saves section titles to be used for
'    generating of the internal navigation links.

'  - Reads &lt;name>.HTM file until it encounterers the line
'    "&lt;!-- Links Start -->".  Every line of input file &lt;name>.HTM gets
'    copied to temporary file &lt;name>.ZZZ; modification date in the first
'    two lines being substituted by modification date from &lt;name>.TXT file.

'  - Skips all lines of &lt;name>.HTM file up to "&lt;!-- Links Finish --> line.

'  - Writes top internal navigation bar to the &lt;name>.ZZZ file.

'  - Converts all links in &lt;name>.TXT file writing their HTML text to the
'    &lt;name>.ZZZ file.

'  - Writes bottom internal navigation bar to the &lt;name>.ZZZ file.

'  - Writes to the &lt;name>.ZZZ file "&lt;!-- Links Finish --> line.

'  - Reads &lt;name>.HTM file up to its end copying every line to &lt;name>.ZZZ
'    file.

'  - Deletes &lt;name>.HTM file.

'  - Renames &lt;name>.ZZZ file file into &lt;name>.HTM file.

' Notes --------------------------------------------------------------------

'  - CONVLNK serves to support the 2-level link hierarchy that is quite
'    sufficient for most practical purposes.

'    1. Link page    within the web  site.
'    2. Link section within the link page.

'  - To avoid any possible problems with the presentation of delimiter lines
'    "&lt;!-- Links Start -->" and  &lt;!-- Links Finish -->" text of lines read
'    gets converted to the upper case before testing for delimiter line,
'    all successive internal spaces get compressed to single space, and
'    external spaces get truncated.

'  - If the line that immediately precedes the "&lt;!-- Links Start -->"
'    delimiter line ends with "&lt;I>", internal inter-section navigation
'    bars at section title get italicized.

'  - CONVLNK is supposed to be triggered by batch script that checks if the
'    &lt;name>.TXT file date-time is later than that of the &lt;name>.HTM file,
'    in which case CONVLNK is called to refresh the &lt;name>.HTM file.

'  - This procedure presumes that ALL changes to the links list are done
'    ONLY in the corresponding &lt;name>.TXT file.  Any direct changes to the
'    links body of the &lt;name>.HTM file will be overwritten by the nearest
'    CONVLNK run.

'  - CONVLNK also is suited to be run from command line to convert the
'    individual links file.  In this case the most simple way is to run
'    CONVLNK within the current directory of the links file.

'  - CONVLNK operation is controlled by processing flags that are defined
'    separately as string constants and are expected to be present in the
'    &lt;name>.HTM file.  Their absence in an anticipated context will yield
'    an unpredictable results.

' External SubProgram Library ----------------------------------------------

     $LINK "MODULE.PBL"

' External Functions -------------------------------------------------------

     DECLARE FUNCTION COMPRES$(Strng$,Chars$)
     DECLARE FUNCTION PARSE%  (Strng$,SubStr$(),Delim$)
     DECLARE FUNCTION REVERSE$(Strng$)
     DECLARE FUNCTION TAILSTR$(Strng$,Delim$)

' External Routine ---------------------------------------------------------

     DECLARE SUB PRNTCLR(Text$)
     DECLARE SUB PROGRES(File%,Nam$,Title$,Record$,Mode$,Appear$)

' Start Procedure ----------------------------------------------------------

     DEFINT A-Z     ' All defaulted variables are integer
     OPTION BASE 1  ' Default array indexation starts from "1"

' Constants ----------------------------------------------------------------

     Q$ =CHR$(34)  ' Quotation mark
     HR$="&lt;HR>&lt;!--------------------------------------------------------------->"

' Processing Flags ---------------------------------------------------------

     Copyright$   ="&lt;!-- Copyright (C)"

     Top.Nav.Bar$ ="Go to:&lt;/FONT>&nbsp; &lt;A HREF="
     Bot.Tag$     ="&lt;A HREF="+Q$+"#Bottom"+Q$+">"

     Links.Start$ ="&lt;!-- LINKS START -->"
     Links.Finish$="&lt;!-- LINKS FINISH -->"

' Working Variables --------------------------------------------------------

     DIM Parameter$(2)
     DIM Repl$(10)
     DIM Src$(10)
     DIM Trg$(10)

' Get and Validate Control Parameter (Links' File Name) --------------------

     Parm$=UCASE$(COMMAND$)
'    Parm$="C:\DEBUG\LINKS-X"        ' Non-existent LINKS-X.TXT file
'    Parm$="C:\DEBUG\LINKS-0"        ' Non-existent LINKS-0.HTM file
'    Parm$="C:\DEBUG\LINKS-1"        ' Single section  layout
'    Parm$="C:\DEBUG\LINKS-2"        ' Two    sections layout
'    Parm$="C:\DEBUG\LINKS-3"        ' Three  sections layout
'    Parm$="C:\DEBUG\LINKS-R"        ' Regular font test (no Italics)
'    Parm$="C:\DEBUG\LINKS-M"        ' Mother's links (special formats)
'    Parm$="C:\DEBUG\LINKS-V,INF-H"  ' Vlad's personal links (toolbar equivalent)

     I=PARSE%(Parm$,Parameter$(),"")

' Form File Name Actual Value ----------------------------------------------

     File.Name$=Parameter$(1)
     IF (File.Name$="") THEN
         File.Name$="LINKS"
     END IF

' Form Replacement Table ---------------------------------------------------

     IF (I>1) THEN
        Replacements=PARSE%(Parameter$(2),Repl$(),"/")
        FOR I=1 TO Replacements
            Src$(I)="%"+EXTRACT$(Repl$(I),"-")+"%"
            Trg$(I)=    TAILSTR$(Repl$(I),"-")
        NEXT I
     END IF

' Check Files' Existence ---------------------------------------------------

     IF (LEN(DIR$(File.Name$+".TXT"))=0) THEN
        CALL PRNTCLR("%R%CONVLNK(2.4)  Text file %M%"+File.Name$+".TXT %R%doesn't exist - %M%program stopped%D%")
        STOP
     END IF

     IF (LEN(DIR$(File.Name$+".HTM"))=0) THEN
        CALL PRNTCLR("%R%CONVLNK(2.4)  Link file %M%"+File.Name$+".TXT %R%doesn't exist - %M%program stopped%D%")
        STOP
     END IF

' Allocate Array for Section Titles ----------------------------------------

     OPEN File.Name$+".TXT" FOR  INPUT AS #2
     LINE INPUT #2,Link.Line$  ' Skip link list title

     WHILE NOT EOF(2)
           LINE INPUT #2,Link.Line$
           IF (LEFT$(Link.Line$,1)&lt;>" ") THEN  ' Section title
              Max.Sections=Max.Sections+1
           END IF
     WEND

     CLOSE

     DIM Section$(Max.Sections)

' Read and Save Section Titles ---------------------------------------------

     OPEN File.Name$+".TXT" FOR  INPUT AS #2
     LINE INPUT #2,Link.Line$  ' Skip link list title

     WHILE NOT EOF(2)
           LINE INPUT #2,Link.Line$
           IF (Link.Line$="") THEN ITERATE  ' Ignore blank line
           IF (LEFT$(LTRIM$(Link.Line$),1)="*") THEN ITERATE  ' Ignore comment line
           IF (VERIFY(Link.Line$,"=")=0) THEN EXIT  ' EOF line of all "="
           IF (LEFT$(Link.Line$,1)&lt;>" ") THEN
              IF (INSTR(Link.Line$,"(")>0) THEN
                 Section.Title$=COMPRES$(LTRIM$(RTRIM$(EXTRACT$(Link.Line$,"(")))," ")
              ELSEIF (INSTR(Link.Line$,"|")>0) THEN
                 Section.Title$=COMPRES$(LTRIM$(RTRIM$(EXTRACT$(Link.Line$,"|")))," ")
              ELSE
                 Section.Title$=LTRIM$(RTRIM$(Link.Line$))
              END IF
              Sections=Sections+1
              Section$(Sections)=Section.Title$
           END IF
     WEND

     CLOSE

' Open Data Files ----------------------------------------------------------

     OPEN File.Name$+".HTM" FOR  INPUT AS #1
     OPEN File.Name$+".TXT" FOR  INPUT AS #2
     OPEN File.Name$+".ZZZ" FOR OUTPUT AS #3

' Get Link List Title and New &lt;name>.HTM Date from &lt;name>.TXT --------------

     CALL PROGRES(1,"CONVLNK(2.4)","Convert Link List "+File.Name$+".TXT"+" into HTML","","S","")

     LINE INPUT #1,HTML.Line$
     LINE INPUT #2,Link.Line$
     PRINT #3,LEFT$(HTML.Line$,LEN(HTML.Line$)-14);RIGHT$(Link.Line$,10);" -->"
     Year$=RIGHT$(Link.Line$,4)

     Work$=LTRIM$(EXTRACT$(Link.Line$,"  "))
     Title$=LEFT$(Work$,1)
     FOR I=2 TO LEN(Work$)-1
         IF (MID$(Work$,I,1)=" ") THEN
            IF ((UCASE$(MID$(Work$,I-1,1))&lt;>LCASE$(MID$(Work$,I-1,1)))AND _
                (UCASE$(MID$(Work$,I+1,1))&lt;>LCASE$(MID$(Work$,I+1,1)))) THEN
               Title$=Title$+"&nbsp; "
            ELSE
               Title$=Title$+" "
            END IF
         ELSE
            Title$=Title$+MID$(Work$,I,1)
         END IF
     NEXT I
     Title$=Title$+RIGHT$(Work$,1)

     LINE INPUT #1,HTML.Line$
     PRINT #3,LEFT$(HTML.Line$,LEN(HTML.Line$)-14);RIGHT$(Link.Line$,10);" -->"

' Insert Converted Links into Links HTML Text ------------------------------

     WHILE NOT EOF(1)
           Prev.Line$=HTML.Line$
           LINE INPUT #1,HTML.Line$
           IF (LEFT$(HTML.Line$,18)=Copyright$) THEN
              PRINT #3,LEFT$(HTML.Line$,24);Year$;MID$(HTML.Line$,29)
           ELSEIF (INSTR(HTML.Line$,Top.Nav.Bar$)>0) THEN
              Top.Nav=-1
              Nav.Length=LEN(EXTRACT$(MID$(LTRIM$(REVERSE$(HTML.Line$)),5),">"))+9
              PRINT #3,HTML.Line$
           ELSEIF (Top.Nav) THEN
              Nav.Length=Nav.Length+LEN(EXTRACT$(MID$(LTRIM$(REVERSE$(HTML.Line$)),5),">"))+3
              PRINT #3,HTML.Line$
              IF (INSTR(HTML.Line$,Bot.Tag$)>0) THEN
                 Top.Nav=0
                 Nav.Length=Nav.Length-3
              END IF
           ELSEIF (UCASE$(LTRIM$(RTRIM$(HTML.Line$)))=Links.Start$) THEN
              Links.Body=-1
              IF (RIGHT$(RTRIM$(Prev.Line$),3)="&lt;I>") THEN
                 Italics=-1
              END IF
              Base.Pos=VERIFY(HTML.Line$," ")
              Base.Pos.4=Base.Pos+4
              Base.Pos.6=Base.Pos+6
              Base.Pos.7=Base.Pos+7
              Base.Pos.8=Base.Pos+8
              Base.Pos.12=Base.Pos+12
              Base.Pos.13=Base.Pos+13
              Base.Pos.18=Base.Pos+18
              Base.Pos.19=Base.Pos+19
              Base.Pos.29=Base.Pos+29
              Base.Pos.37=Base.Pos+37
              PRINT #3,TAB(Base.Pos);"&lt;!-- Links Start -->"
           ELSEIF (UCASE$(LTRIM$(RTRIM$(HTML.Line$)))=Links.Finish$) THEN
              Links.Body=0
              GOSUB Convert.and.Insert.Links
              PRINT #3,TAB(Base.Pos);"&lt;!-- Links Finish -->"
           ELSEIF (NOT Links.Body) THEN
              PRINT #3,HTML.Line$
           END IF
     WEND

' Finish Program -----------------------------------------------------------

     CALL PROGRES(1,"","","","F","")

     CLOSE

     KILL File.Name$+".HTM"
     NAME File.Name$+".ZZZ" AS File.Name$+".HTM"

     END

Convert.and.Insert.Links:  ' Routine ---------------------------------------

     GOSUB Write.Internal.Navigation.Bar

     WHILE NOT EOF(2)
           LINE INPUT #2,Link.Line$
           CALL PROGRES(1,"","",Link.Line$,"P","")
           IF (Link.Line$="") THEN ITERATE  ' Ignore blank line
           IF (LEFT$(LTRIM$(Link.Line$),1)="*") THEN ITERATE  ' Ignore comment line
           IF (VERIFY(Link.Line$,"=")=0) THEN EXIT  ' EOF line of all "="
           IF (Replacements>0) THEN
              FOR I=1 TO Replacements
                  REPLACE Src$(I) WITH Trg$(I) IN Link.Line$
              NEXT I
           END IF
           IF (LEFT$(Link.Line$,1)&lt;>" ") THEN  ' Process section header
              Curr.Sect=Curr.Sect+1
              IF (INSTR(Link.Line$,"|")>0) THEN
                 Section.Title$=COMPRES$(LTRIM$(RTRIM$(EXTRACT$(Link.Line$,"|")))," ")
                 Section.Link$ =COMPRES$(LTRIM$(RTRIM$(TAILSTR$(Link.Line$,"|")))," ")
              ELSE
                 Section.Title$=LTRIM$(RTRIM$(Link.Line$))
                 Section.Link$ =""
              END IF
              IF (INSTR(Section.Title$,"(")>0) THEN
                 Section.Comm$ ="("+LTRIM$(RTRIM$(TAILSTR$(Section.Title$,"(")))+"&nbsp;"
                 Section.Title$=    LTRIM$(RTRIM$(EXTRACT$(Section.Title$,"(")))
              ELSE
                 Section.Comm$ =""
              END IF
              GOSUB Write.Section.Entry
           ELSE  ' Process link
              Link.Name$=COMPRES$(LTRIM$(RTRIM$(EXTRACT$(Link.Line$,"|")))," ")
              Link.URL$ =COMPRES$(LTRIM$(RTRIM$(TAILSTR$(Link.Line$,"|")))," ")
              IF (LEFT$(Link.URL$,1)="_") THEN
                 Link.URL$=MID$(Link.URL$,2)
              ELSEIF (INSTR(LEFT$(Link.URL$,8),"://")=0) THEN
                 Link.URL$="http://"+Link.URL$
              END IF
              Link.Comm$=""
              IF (INSTR(Link.Name$,"(")>0) THEN
                 Link.Comm$="("+TAILSTR$(Link.Name$,"(")
                 Link.Name$=RTRIM$(LTRIM$(EXTRACT$(Link.Name$,"(")))
              END IF
              GOSUB Write.Link.Entry
           END IF
     WEND

     GOSUB Write.Internal.Navigation.Bar

     RETURN  ' From Convert.and.Insert.Links routine

Write.Internal.Navigation.Bar:  ' Routine ----------------------------------

     IF (Sections=1) THEN RETURN  ' From Write.Internal.Navigation.Bar Routine

     Top.Bar=(Curr.Sect=0)

     IF (NOT(Top.Bar)) THEN  ' Bottom internal navigation bar
        PRINT #3,TAB(Base.Pos);HR$
     END IF

     PRINT #3,TAB(Base.Pos);"&lt;CENTER>"
     PRINT #3,TAB(Base.Pos);"  &lt;FONT COLOR=Green>&nbsp;Go to:&lt;/FONT>&nbsp;"
     Bar.Length=8

     FOR I=1-Top.Bar TO Sections  ' Start with "2" for Top Bar
         IF (Bar.Length+3+LEN(Section$(I))&lt;Nav.Length) THEN
            IF (I=1-Top.Bar) THEN
               PRINT #3,TAB(Base.Pos.29);"&lt;A HREF=";Q$;"#";Section$(I);Q$;">";Section$(I);"&lt;/A>"
               Bar.Length=Bar.Length+LEN(Section$(I))
            ELSE
               PRINT #3,TAB(Base.Pos);"  &lt;FONT COLOR=Green>|&lt;/FONT> &lt;A HREF=";Q$;"#";Section$(I);Q$;">";Section$(I);"&lt;/A> "
               Bar.Length=Bar.Length+LEN(Section$(I))+3
            END IF
         ELSE
            PRINT #3,TAB(Base.Pos.13);"&nbsp;&lt;BR>&nbsp;&lt;A HREF=";Q$;"#";Section$(I);Q$;">";Section$(I);"&lt;/A>"
            Bar.Length=LEN(Section$(I))
         END IF
     NEXT I

     PRINT #3,TAB(Base.Pos);"&lt;/CENTER>"
     IF (Top.Bar) THEN
        PRINT #3,TAB(Base.Pos);HR$
     END IF

     RETURN  ' From Write.Internal.Navigation.Bar routine

Write.Section.Entry:  ' Routine --------------------------------------------

     IF (Curr.Sect=1) THEN
        PRINT #3,TAB(Base.Pos);"&lt;CENTER>&lt;FONT SIZE=4 COLOR=Red>&lt;B>&lt;U>";Title$;"&lt;/U>&lt;/B>&lt;/FONT>&lt;/CENTER>"
        PRINT #3,TAB(Base.Pos);"&lt;BR>&lt;!--------------------------------------------------------------->"
     ELSE
        PRINT #3,TAB(Base.Pos);HR$
     END IF

     IF (Sections=1) THEN
        PRINT #3,TAB(Base.Pos.4);
        GOSUB Write.Section.Title
        RETURN  ' From Write.Section.Title routine
     END IF

     PRINT #3,TAB(Base.Pos.4);"&lt;A NAME=";Q$;Section.Title$;Q$;">&lt;/A>"
     PRINT #3,TAB(Base.Pos.4);"&lt;TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>"
     PRINT #3,TAB(Base.Pos.6);"&lt;TR>"
     PRINT #3,TAB(Base.Pos.8);"&lt;TD>";
     GOSUB Write.Section.Title
     PRINT #3,"&lt;/TD>"

     PRINT #3,TAB(Base.Pos.8);"&lt;TD ALIGN=Right>"
     IF (Italics) THEN
        PRINT #3,TAB(Base.Pos.8);"  &lt;I>"
     END IF
     PRINT #3,TAB(Base.Pos.8);"    &lt;FONT COLOR=Green>Go to:&lt;/FONT>&nbsp;"
     PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#Top";Q$;">List top&lt;/A>"

     IF (Curr.Sect=1) THEN
        PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
        PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#";Section$(Curr.Sect+1);Q$;">Next section&lt;/A>"
        PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
        PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#Bottom";Q$;">List bottom&lt;/A>&nbsp;"
     ELSEIF (Curr.Sect=Sections) THEN
        PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
        PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#";Section$(Curr.Sect-1);Q$;">Previous section&lt;/A>"
        PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
        PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#Bottom";Q$;">List bottom&lt;/A>&nbsp;"
     ELSE
        IF (Curr.Sect>1) THEN
           PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
           PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#";Section$(Curr.Sect-1);Q$;">Prev sect&lt;/A>"
        END IF
        IF (Curr.Sect&lt;Sections) THEN
           PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
           PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#";Section$(Curr.Sect+1);Q$;">Next sect&lt;/A>"
        END IF
        PRINT #3,TAB(Base.Pos.12);"&lt;FONT COLOR=Green>|&lt;/FONT>"
        PRINT #3,TAB(Base.Pos.37);"&lt;A HREF=";Q$;"#Bottom";Q$;">List bot&lt;/A>&nbsp;"
     END IF

     IF (Italics) THEN
        PRINT #3,TAB(Base.Pos.8);"  &lt;/I>"
     END IF
     PRINT #3,TAB(Base.Pos.8);"&lt;/TD>"
     PRINT #3,TAB(Base.Pos.6);"&lt;/TR>"
     PRINT #3,TAB(Base.Pos.4);"&lt;/TABLE>"

     First.Link=-1  ' For spec prefix of the first link after section title
                    ' (for the multisection page only)

     RETURN  ' From Write.Section.Entry routine

Write.Link.Entry:  ' Routine -----------------------------------------------

     IF (First.Link) THEN
        PRINT #3,TAB(Base.Pos.4);"&nbsp; &nbsp; &nbsp;"
        First.Link=0
     ELSE
        PRINT #3,TAB(Base.Pos);"&lt;BR>&nbsp; &nbsp; &nbsp;"
     END IF

     PRINT #3,TAB(Base.Pos.4);"&lt;A HREF=";Q$;Link.URL$;Q$;">"

     PRINT #3,TAB(Base.Pos.7);Link.Name$;"&lt;/A>";
     IF (Link.Comm$&lt;>"") THEN
        PRINT #3,"&nbsp; ";Link.Comm$
     END IF

     RETURN  ' From Write.Section.Link routine

Write.Section.Title:  ' Routine --------------------------------------------

     IF (Section.Link$ ="") THEN
        IF (Italics) THEN
           PRINT #3,"&nbsp;&lt;FONT COLOR=Navy>&lt;I>&lt;B>";Section.Title$;"&lt;/B>&lt;/I>&lt;/FONT>";
        ELSE
           PRINT #3,"&nbsp;&lt;FONT COLOR=Navy>&lt;B>";Section.Title$;"&lt;/B>&lt;/FONT>";
        END IF
     ELSE
        IF (Italics) THEN
           PRINT #3,"&nbsp;&lt;A HREF=";Q$;Section.Link$;Q$;">&lt;I>&lt;B>";Section.Title$;"&lt;/B>&lt;/I>&lt;/A>";
        ELSE
           PRINT #3,"&nbsp;&lt;A HREF=";Q$;Section.Link$;Q$;">&lt;B>";Section.Title$;"&lt;/B>&lt;/A>";
        END IF
     END IF

     IF (Section.Comm$&lt;>"") THEN
        IF (Italics) THEN
           PRINT #3,"&nbsp; &lt;I>";Section.Comm$;"&lt;/I>";
        ELSE
           PRINT #3,"&nbsp; ";Section.Comm$;
        END IF
     END IF

     RETURN  ' From Write.Section.Title routine
