Comment
==========================================================
This program turns Ralf Brown's Interrupt List into HTML
==========================================================
EndComment
var
ChapterNumber
OutF
PreMode
WrapTextList
SeeAlsoNum
SeeAlsoKey
SeeAlsoInt
Table
Table2
Index
IndexFile
NameMode
CatList
CatList2
Base
Alpha
Text
Base = 'F:\HTML\INTR\'
Setup
Main
WriteAscTextFile('TABLE.ASC',Table)
Writeln 'Reading INDEX.ASC ...'
ReadAscTextFile('INDEX.ASC',Index)
WriteAscTextFile('INDEX2.ASC',Index)
BuildIntIndexes
BuildAlphaIndexes
BuildCatIndexes
ExitMenu
;=============================================================
Procedure KbdAbort
if KbdReady
if ReadKey = Esc then ExitMenu
endif
EndProc
Procedure MakeChapterName (N)
var Name
Name = Str(N)
while length(Name) < 4
Name = '0' + Name
endwhile
Return 'rb' + Name + '.htm'
EndProc
Procedure MakeIntName (N)
var Name
Name = Str(N)
while length(Name) < 3
Name = '0' + Name
endwhile
Return 'int' + Name + '.htm'
EndProc
Procedure MakeAlphaName (N)
var Name
Name = Str(N-63)
while length(Name) < 2
Name = '0' + Name
endwhile
Return 'al' + Name + '.htm'
EndProc
Procedure MakeCatName (N)
var Name
Name = Str(N)
while length(Name) < 2
Name = '0' + Name
endwhile
Return 'cat' + Name + '.htm'
EndProc
Procedure MakeContentsName (N)
var Name
N = N + 1 mod 3
if N = 0
Name = 'int.htm'
elseif N = 1
Name = 'cat.htm'
else
Name = 'alpha.htm'
endif
Return Name
EndProc
Procedure MakeName (N)
if NameMode = 1
Return MakeChapterName(N)
elseif NameMode = 2
Return MakeIntName(N)
elseif NameMode = 3
Return MakeAlphaName(N)
elseif NameMode = 4
Return MakeCatName(N)
elseif NameMode = 5
Return MakeContentsName(N)
endif
EndProc
Procedure UnIndent (St,N)
N = 0
while (St > '') and (Left(St,1) = ' ')
N = N + 1
delete(St,1,1)
endwhile
EndProc
Procedure CapFirstCharacter (St)
Mid(St,1) = UpperCase(Left(St,1))
EndProc
Procedure WrapText (St)
Return PosInListLeft(St,WrapTextList) > 0
EndProc
Procedure ProcessTextBody (IntNum)
var Section St St2 St3 St4 St5 IntNum2 IntNum3 P B I SA
Section = ''
Loop Text
St = ColonCommand(LoopVal)
UnIndent(Loc LoopVal,Loc P)
if St > ''
Section = St
if St = 'Return:'
if LoopIndex > 1
Text[LoopIndex - 1] = Text[LoopIndex - 1] + '
'
endif
endif
;- Here's where we turn SeeAlso into hot links
if St = 'SeeAlso:'
St2 = 'SeeAlso: '
St = NextWordDelim(LoopVal,'')
while LoopVal > ''
B = pos(',',LoopVal)
if B = 0 then B = 255
St = Left(LoopVal,B-1)
St3 = St
delete(LoopVal,1,B)
if not (St StartsWith 'INT')
St = IntNum + '/' + St
endif
while pos('"',St) > 0
delete(St,pos('"',St),1)
endwhile
B = PosInListLeft(St,SeeAlsoKey)
if B > 0
;- Found it!
St2 = St2 + ''
St2 = St2 + St3 + ' - '
else
;- Not Found
B = pos('"',St3)
if B > 0
if St3 StartsWith 'INT'
IntNum3 = St3
delete(IntNum3,1,4)
IntNum2 = Value('$' + Left(IntNum3,2))
else
IntNum2 = IntNum
P = pos(' ',IntNum2)
if P > 0
delete(IntNum2,1,P)
endif
P = pos('/',IntNum2)
if P > 0
IntNum2 = Left(IntNum2,P-1)
endif
IntNum2 = Value('$' + IntNum2)
endif
St4 = Left(St3,B-1)
delete(St3,1,B-1)
St5 = St3
St5 = NextWord(St5)
;- St5 is new key
B = PosInListPartial(St5,SeeAlsoInt[IntNum2+1,1])
if B > 0
;- Found it!
B = SeeAlsoInt[IntNum2+1,2,B]
St2 = St2 + ''
St2 = St2 + St4 + St3 + ' - '
else
;- Still Not Found
St2 = St2 + ''
St2 = St2 + St4 + '' + St3 + ' - '
endif
else
St2 = St2 + St3 + ' - '
endif
endif
endwhile
length(St2) = length(St2) - 3
LoopVal = St2
endif
endif
if (Section <> '') and (Section <> 'Return:')
if P = 8
if LoopIndex > 1
Text[LoopIndex - 1] = Text[LoopIndex - 1] + '.'
endif
CapFirstCharacter(Loc LoopVal)
endif
endif
EndLoop
Section = ''
Loop Text
St = ColonCommand(Loc LoopVal)
if St > ''
Section = St
if WrapText(Section)
SetPreMode Off
Wr '
' Section '' CapFirstCharacter(Loc LoopVal) Wr LoopVal else SetPreMode On CapFirstCharacter(Loc LoopVal) Wr '
' Section '
' LoopVal
endif
else
if LoopVal = ''
SetPreMode On
LoopVal = '
' else P = pos('(TABLE',LoopVal) if P > 0 St = mid(LoopVal,P + 7,255) I[1] = Value(NextWord(St)) I[2] = ChapterNumber AppendArray(Table,I) endif P = pos('(SEE',LoopVal) if P > 0 St = LoopVal St2 = mid(St,P,11) B = Value(mid(St,P + 6,4)) delete(St,P,11) St3 = '' St3 = St3 + St2 + '' insert(St3,St,P) LoopVal = St endif endif Wr LoopVal endif EndLoop EndProc Procedure ProcessAFile (Name) var T F Line Category Index St OutName P I var Title Title2 IntNum FirstChar FileAssign(F,Name) FileOpen(F) while not EndOfFile(F) Line = FileReadln(F) if Line StartsWith '--------' ;- Process the file if Category <> 'Information' if ChapterNumber > 0 OutName = MakeChapterName(ChapterNumber) Writeln 'Creating File: ' OutName FileAssign(OutF,Base + OutName) FileCreate(OutF) Title = '' ;- Build the Title Loop Index Title = Title + LoopVal + '/' EndLoop Length(Title) = Length(Title) - 1 Wr '' Wr '
' Wr '' Indexes(ChapterNumber) Wr AddLine ;- Process Line 1 Title2 = Text[1] delete(Text,1,1) while pos('"',Title2) > 0 delete(Title2,pos('"',Title2),1) endwhile P = Pos('-',Title2) if P > 0 delete(Title2,1,P) Trim(Title2) CapFirstCharacter(loc Title2) endif if pos('NETWARE',Title2) > 0 Category = 'Netware' endif if pos('VIRUS',Title2) > 0 Category = 'Viruses' endif IntNum = Index[1] P = pos(' ',IntNum) if P > 0 delete(IntNum,1,P) endif IntNum = Value('$' + IntNum) Wr '' Title2 '' if pos(': ',Text[1]) = 0 SetPreMode On endif ProcessTextBody (Index[1]) SetPreMode Off Wr '
P = PosInList(Category,CatList2) Wr 'Category: ' Wr Category '' Wr '- ' Wr 'Int ' HexString(IntNum,2) 'h' FirstChar = left(Title2,1) if FirstChar < '@' then FirstChar = '@' if FirstChar > 'Z' then FirstChar = 'Z' Wr '- ' Wr FirstChar '' Wr '
' AddLine Indexes(ChapterNumber) Wr '' Wr '