'**************************************** 'KeyCollector '**************************************** Sub MAIN Dim ErrorLev, ffPath$, ffCSV$, UseRTF ErrorLev = 0 GetProjDir ffPath$, ffCSV$, ErrorLev 'What you'd think If ErrorLev <> 0 Then Goto Quit JustDir ffPath$ 'Separate the path from the file name... ChDir ffPath$ '...and change to that directory JustName ffCSV$ 'Separate the file name from the path GetKeys ffCSV$ Close #1 Close #2 MsgBox "The keywords have been collected in KEYS.CSV." Quit: End Sub '**************************************** Sub GetProjDir(ffPath$, ffCSV$, ErrorLev) Dim NumFndFiles, i, n FileFind .Location = "All local drives", .Name = "tracker.csv", .Options = 0, .SortBy = 4 NumFndFiles = CountFoundFiles() Dim HPJ$(NumFndFiles) For i = 1 To NumFndFiles HPJ$(i - 1) = FoundFileName$(i) Next Begin Dialog UserDialog 558, 142, "Choose a project file" ListBox 14, 43, 414, 84, HPJ$(), .ListBox1 OKButton 448, 43, 88, 21 CancelButton 448, 67, 88, 21 Text 14, 9, 475, 13, "Choose the Windows Help project from which to collect" Text 14, 22, 187, 13, "the footnote information." End Dialog Dim HPJ As UserDialog n = Dialog(HPJ) 'Figure out how to do On Error here If n = 0 Then ErrorLev = 1 ffCSV$ = HPJ$(HPJ.ListBox1) ffPath$ = ffCSV$ End Sub '**************************************** Sub GetKeys(ffCSV$) Dim ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$ Dim ffKeyWord$, Comments$, BuildTag$, EntryMacro$ Dim n Open ffCSV$ For Input As #1 Open "keys.csv" For Output As #2 'Get the first line out of the way, which just contains titles Read #1, ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, ffKeyWord$, \ Comments$, BuildTag$, EntryMacro$ On Error Goto errorhandler done = 0 : n = 1 While done = 0 Read #1, ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, ffKeyWord$, \ Comments$, BuildTag$, EntryMacro$ Goto cont errorhandler: ffKeyword$ = "String too long error" err = 0 cont: done = Eof(1) Print n : n = n + 1 ' If you want to write everything to a file, instead of just the keywords, ' titles, and filenames, then unREM the next 2 lines, and REM the line below. ' ParseAndWrite ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, ffKeyWord$, \ ' Comments$, BuildTag$, EntryMacro$ ParseAndWrite ffFile$, ffTitle$, ffKeyWord$ Wend End Sub '**************************************** ' If you want to write everything to a file, instead of just the keywords, ' titles, and filenames, then unREM the next 2 lines, and REM the line below. ' Sub ParseAndWrite(ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, ffKeyWord$, \ ' Comments$, BuildTag$, EntryMacro$) Sub ParseAndWrite(ffFile$, ffTitle$, ffKeyWord$) Dim done, s, temp$, KeyLength, k$ done = 0 : s = 0 : temp$ = "" : KeyLength = Len(ffKeyWord$) While s < KeyLength k$ = Mid$(ffKeyWord$, s + 1, 1) If k$ = ";" Then ' If you want to write everything to a file, instead of just the keywords, ' titles, and filenames, then unREM the next 2 lines, and REM the line below. ' Write #2, ffKeyWord$, ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, \ ' Comments$, BuildTag$, EntryMacro$ Write #2, temp$, ffTitle$, ffFile$ temp$ = "" s = s + 1 Else temp$ = temp$ + k$ s = s + 1 EndIf Wend ' If you want to write everything to a file, instead of just the keywords, ' titles, and filenames, then unREM the next 2 lines, and REM the line below. ' If temp$ <> "" Then Write #2, ffKeyWord$, ffFile$, ffTitle$, KeyTitle$, HelpID$, Browse$, \ ' Comments$, BuildTag$, EntryMacro$ If temp$ <> "" Then Write #2, temp$, ffTitle$, ffFile$ End Sub '**************************************** Sub JustDir(t$) 'Separate the path from the file name Dim i i = Len(t$) While Mid$(t$, i, 1) <> "\" i = i - 1 Wend i = i - 1 t$ = Left$(t$, i) End Sub '**************************************** Sub JustName(t$) 'Separate the file name from the path Dim i i = Len(t$) While Mid$(t$, i, 1) <> "\" i = i - 1 Wend i = Len(t$) - i t$ = Right$(t$, i) End Sub