Older Version
Newer Version
JackBurman
May 6, 2011
' LB Help Search entry
' Author: jaba
' Date: May 5, 2011
'
' History:
' v1.0 May 6, 2011 Submitted
'
'
' This code is free for personal use.
'
' Based on a framework provided by Alyce on LB forum.
'
' Some parts taken from entries by others, including
' Alyce, Janet, Stefan, and Gordon.
'
' Thanks to them and others.
'
' This is a basic and minimum interface which uses the default browser
' to display search terms. As I learn more, I may include a browser control
' in the interface, which I think is the best and fastest way to display
' the search terms. But, for now, I'm happy to be making a submission.
'
' To display the Reserved Word List, I edited the .htm file and saved it
' as a .txt file in my /HTML/ sub folder. The user will see the html
' file in the lower textbox, which includes html tags. I have not made a
' parser yet, or included the browser control to display html files.
' At this point, it's an idea only.
'
HelpDir$ = StartupDir$ + "lb4help\LibertyBASIC_4_web\HTML\"
ReservedWordPage$ = HelpDir$ + "libe6ldg.htm"'"libe6ldg.txt"
HelpFileIndex$ = StartupDir$; "lb4help\LibertyBASIC_4.html"
nomainwin
WindowWidth = 442
WindowHeight = 520
UpperLeftX = DisplayWidth - WindowWidth
UpperLeftY = 40
statictext #s.search "Search for: ", 10, 15, 200, 20
textbox #s.term 10, 35, 320, 25
button #s.default "Find", [getIt], UL, 340, 35, 80, 25
listbox #s.pages, found$(), [ListPages], 10, 65, 410, 200
statictext #s.heading "Commands and Reserved Word List", 10, 270, 300, 20
stylebits #s.reserved, _WS_VSCROLL, _ES_AUTOHSCROLL, 0, 0
textbox #s.reserved 10, 290, 410, 170
button #s.content "Contents", [startBrowser], UL, 340, 5, 80, 25
open "Search Me!" for dialog_nf as #s
#s "trapclose [quit]"
#s.content "!font ms_sans_serif 9 bold"
#s.search "!font ms_sans_serif 9 bold"
#s.heading "!font ms_sans_serif 9 bold"
#s.reserved "!font courier_new 8"
#s.reserved ReservedWordList$(ReservedWordPage$)
#s.term "!setfocus"
dim info$(10,10)
files HelpDir$, "*.htm", info$()
numFiles = val(info$(0,0))
wait
[getIt]
#s.term "!contents? term$"
dim found$(numFiles)
for i = 1 to numFiles
open HelpDir$ + info$(i,0) for input as #file
txt$ = INPUT$(#file, lof(#file))
if instr(txt$, term$) >0 then
found$(i) = GetTitle$(txt$); chr$(0); info$(i,0)
#s.pages "reload"
end if
close #file
next
wait
[ListPages]
#s.pages "selection? FileName$"
FileName$ = word$(FileName$, 2, chr$(0))
run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpDir$; FileName$; chr$(34)
wait
[startBrowser]
run "rundll32.exe url.dll,FileProtocolHandler "; chr$(34); HelpFileIndex$; chr$(34)
#s.term "!setfocus"
wait
[quit]
'How can I close browser window programmatically?
notice "Be sure to close browser!"
close #s
end
'credit: Alyce's entry.
'extract title from html text
function GetTitle$(s$)
marker1=instr(upper$(s$), "<A NAME=")
marker1=instr(upper$(s$), "<B>",marker1)+3
marker2=instr(upper$(s$), "</B>", marker1)
lenTitle=marker2-marker1
GetTitle$=mid$(s$,marker1,lenTitle)
end function
function ReservedWordList$(page$)
open page$ for input as #file
ReservedWordList$ = INPUT$(#file, lof(#file))
close #file
end function