Author Topic: Free search in a CHM file  (Read 539 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11604
  • Assembler is fun ;-)
    • MasmBasic
Free search in a CHM file
« on: April 27, 2021, 06:56:22 PM »
For a friend in the FreeBasic forum:

0. Be prepared to see virus warnings: AV software hates assembly code. Ignore the warnings if you want to use this software, but here is the legal disclaimer: using my stuff is at your own risk.
1. Create a folder ChmSearch
2. Open the chm file (e.g. FB-manual-1.07.2.chm) in 7-zip
3. Extract all html files to the ChmSearch folder
4. From the attachment, extract the two executables to this folder
5. Run Extract.exe

From now on, dragging the *.jjn file over JNotes.exe allows a pretty fast search. Here is a screenshot:



The Manual for JNotes.exe:
- two search strings are allowed
- if the first one is all lowercase, search is case-insensitive
- right-click for favourites (confirm saving of settings when exiting)

P.S.: The source:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Dim o$()
  GetFiles *.ht*                ; htm & html
  For_ ct=0 To eax-1
        mov ecx, Files$(ct)
        Let esi=FileRead$(ecx)
        Let edi=Extract$(esi, "<title>", "</title>")
        .if byte ptr [edi]=="?"
                Let edi=Left$(ecx, Instr_(ecx, ".html", 1)-1)  ; no title found: use filename
        .endif
        Let o$(ct)="@="+edi+CrLf$+NoTag$(esi)
  Next
  mov ecx, CurDir$(0)
  Let edi=Mid$(ecx, Rinstr(ecx, "\")+1)+".jjn"
  Store edi, o$()
  Launch Cat$("JNotes.exe "+edi)
EndOfCode
« Last Edit: April 28, 2021, 06:55:05 AM by jj2007 »