|
Post by cundo on Jun 3, 2020 18:34:48 GMT
I made another help file scanner, please try it. It's really simple.
' another help file viewer ' (C) 2020 by cundo ' find this code and discussion at justbasiccom.proboards.com ' version: 1001 nomainwin if Version$<>"2.0" then notice "Just BASIC 2.0 required" end end if if fileExists(StartupDir$, "jbasic.exe")=0 then notice "Please, run this bas file or tkn from ";_ "the Just BASIC IDE (launch it from the desktop or the start menu)" end end if
WindowWidth = 228 : WindowHeight = 500 UpperLeftX= 1 UpperLeftY= 1 dim ar$(1000),searchList$(1000) global helpFilePath$ helpFilePath$ = StartupDir$;"jb2help\JustBASIC_2_web" helpFileMenu$ = "amber_menu.htm"
if fileExists(helpFilePath$, helpFileMenu$)=0 then notice "Program Terminated";chr$(13);_ "Couldn't find the help files" end end if
open helpFilePath$; "\"; helpFileMenu$ for input as #1 txt$ = input$(#1, lof(#1))
close #1
' do a lower case version of the htm file ' to avoid discrepances or whatever. lowerTxt$= lower$(txt$)
while 1 scan
startAt = c+1 a = instr(lowerTxt$, "href",startAt) b = instr(lowerTxt$, ">",a+1) c = instr(lowerTxt$, "</a>",b+1)
if a=0 or b=0 or c= 0 then exit while
hrefA= instr(lowerTxt$,chr$(34),a+1) hrefB= instr(lowerTxt$,chr$(34),hrefA+1) idx = idx +1 ar$(idx)= trim$(mid$(txt$,b+1,c-b-1));chr$(0);_ trim$(mid$(txt$,hrefA+1,hrefB-hrefA-1))
wend
listbox #main.listbox1, ar$(, lbDoubleClick, 8, 48, 200, 400 textbox #main.tb 8,49,148,32 listbox #main.listbox2, searchList$(, lbDoubleClick, 8, 96, 200, 352 button #main.contents, "&Contents", buttonClick, UL, 8, 8, 100, 30 button #main.search, "&Search", buttonClick, UL, 110, 8, 100, 30 button #main.default, "&Go", buttonClick, UL, 160, 49, 46, 32 open "JB Help" for dialog_nf as #main #main "trapclose quit" #main "font Arial 10" #main.listbox2 "hide" : #main.tb "!hide" : #main.default "!hide"
wait
sub quit h$ close #h$ : end end sub
sub buttonClick h$
select case word$(h$,2,".") case "contents" #main.listbox1 "show" : #main.listbox2 "hide" : #main.tb "!hide" :#main.default "!hide" case "search" #main.listbox1 "hide" : #main.listbox2 "show" : #main.tb "!show" : #main.default "!show" #main.tb "!setfocus" case "default"
#main.tb "!contents? searchFor$"
searchFor$=trim$(searchFor$)
if len(searchFor$)>2 then cursor hourglass redim searchList$(1000) for i = 1 to 500 ' so so if ar$(i)="" then exit for fileToOpen$= word$(ar$(i),2,chr$(0)) open helpFilePath$; "\"; fileToOpen$ for input as #2 contents$ = input$(#2, lof(#2)) '#main.texteditor contents$ if instr(lower$(contents$), lower$(searchFor$)) then count=count+1 searchList$(count)= ar$(i) end if close #2 next i #main.listbox2 "reload" cursor normal else notice "More than 2 character please." end if end select end sub
sub lbDoubleClick h$ #h$ "selection? selection$" if selection$ = "" then exit sub
fileToOpen$= word$( selection$,2,chr$(0))
fileToOpen$=replace$( fileToOpen$ , "/", "\" ) run "explorer.exe ";helpFilePath$; "\"; fileToOpen$ exit sub
' open helpFilePath$; "\"; fileToOpen$ for input as #2 ' contents$ = input$(#2, lof(#2)) '#main.texteditor contents$ ' close #2 ' #main.texteditor "!cls" ' #main.texteditor "!origin 0 0"
end sub
function fileExists(path$, filename$) dim fileExistsInfo$(0,0) files path$, filename$, fileExistsInfo$() fileExists = val(fileExistsInfo$(0, 0)) 'non zero is true end function
function replace$( text$ , this$, tothis$ ) while 1 if instr(text$, this$) then nbspA = instr(text$, this$) lenght=len(this$) text$ = mid$(text$,1,nbspA-1);_ tothis$;mid$(text$,nbspA+lenght) else exit while end if wend replace$=text$ end function
|
|
|
Post by B+ on Jun 3, 2020 19:14:14 GMT
Yeah works once I figured to dbl-click list item. Well there's a different perspective to help info, cool!
|
|
|
Post by cundo on Jun 3, 2020 20:17:50 GMT
Sorry I forgot to add some directions. Thanks for testing it.
|
|
|
Post by cundo on Jun 3, 2020 21:53:38 GMT
What text should I use? Currently have something like: " double click on an item from the list to..." I'm not sure about the "on an"
|
|
|
Post by tsh73 on Jun 4, 2020 7:21:41 GMT
Wow cool. Made it a TKN and put to External programs.
|
|
|
Post by Rod on Jun 4, 2020 8:19:58 GMT
Yes this is really nice and very useful for beginners. I added a couple of single click commands, I prefer that instant response.
open "JB Help" for dialog_nf as #main #main "trapclose quit" #main "font Arial 10" #main.listbox2 "hide" : #main.tb "!hide" : #main.default "!hide" #main.listbox1 "singleclickselect" #main.listbox2 "singleclickselect" wait
As tsh73 says, create a tkn in the StartupDir$ and add it to external programs list. I would do a step by step instruction set and add that above your code.
|
|
|
Post by cundo on Jun 4, 2020 21:30:27 GMT
Ok I've added a singleclick selection, and I'm writing a short tutorial. Should the program close after picking an item from the list?
|
|
|
Post by Rod on Jun 5, 2020 6:18:07 GMT
No, my intention is to leave it open. Folks may have their browser open anyway. Leave it to the user.
|
|
|
Post by cundo on Jun 5, 2020 15:13:12 GMT
Version 2
' another help file viewer ' (C) 2020 by cundo ' find this code and discussion at justbasiccom.proboards.com ' version: 1002 nomainwin
if VAL(Version$)<2 then notice "Just BASIC 2.0 required" end end if if fileExists(StartupDir$, "jbasic.exe")=0 then notice "Please, run this bas file or tkn from ";_ "the Just BASIC IDE (launch it from the desktop or the start menu)" end end if
WindowWidth = 228 : WindowHeight = 514 UpperLeftX= 1 : UpperLeftY= 1 dim ar$(1000),searchList$(1000) global helpFilePath$ helpFilePath$ = StartupDir$;"jb2help\JustBASIC_2_web" helpFileMenu$ = "amber_menu.htm"
if fileExists(helpFilePath$, helpFileMenu$)=0 then notice "Program Terminated";chr$(13);_ "Couldn't find the help files" end end if
open helpFilePath$; "\"; helpFileMenu$ for input as #1 txt$ = input$(#1, lof(#1)) close #1
' do a lower case version of the html file ' to avoid discrepances or whatever. lowerTxt$= lower$(txt$)
while 1 scan
startAt = c+1 a = instr(lowerTxt$, "href",startAt) b = instr(lowerTxt$, ">",a+1) c = instr(lowerTxt$, "</a>",b+1)
if a=0 or b=0 or c= 0 then exit while
hrefA= instr(lowerTxt$,chr$(34),a+1) hrefB= instr(lowerTxt$,chr$(34),hrefA+1) idx = idx +1 ar$(idx)= trim$(mid$(txt$,b+1,c-b-1));chr$(0);_ trim$(mid$(txt$,hrefA+1,hrefB-hrefA-1))
wend
listbox #main.listbox1, ar$(, lbDoubleClick, 8, 48, 200, 400 textbox #main.tb 8,49,148,32 listbox #main.listbox2, searchList$(, lbDoubleClick, 8, 96, 200, 352 button #main.contents, "&Contents", buttonClick, UL, 8, 8, 80, 30 button #main.search, "&Search", buttonClick, UL, 90, 8, 90, 30 button #main.help, "?", buttonClick, UL, 182, 8, 26, 30 instructions$ = "Select an item from the ";_ "list to view the article on your web browser." 'statictext #main.st, instructions$,12,460,180,32 button #main.default, "&Go", buttonClick, UL, 160, 49, 46, 32
open "JB Help" for dialog_nf as #main
#main "trapclose quit" #main "font Arial 12" #main.listbox1 "singleclickselect" #main.listbox2 "singleclickselect" #main.listbox2 "hide" : #main.tb "!hide" : #main.default "!hide"
wait
sub quit h$ close #h$ : end end sub
sub buttonClick h$
select case word$(h$,2,".") case "contents" #main.listbox1 "show" : #main.listbox2 "hide" : #main.tb "!hide" :#main.default "!hide" case "search" #main.listbox1 "hide" : #main.listbox2 "show" : #main.tb "!show" : #main.default "!show" #main.tb "!setfocus" case "help"
notice "Help";CHR$(13);_ "From the Contents list, single click an";_ " item and the web browser will display the topic.";_ CHR$(13);CHR$(13);_ "From the Search list (empty at start), write";_ " a word, and press the Enter key or press the Go button, to search.";_ CHR$(13);CHR$(13);_ "How to append this program to the Just BASIC Run menu for easy access.";_ CHR$(13);_ "1) Tokenize this program's code: Run menu > Make *.tkn File.";_ " Use any name for the file,";_ " remember where this file is, and how it is named.";_ CHR$(13);_ "2) Select the menu Setup > External Programs";_ CHR$(13);_ "3) Click on the New button, choose a name of your liking to create a new item.";_ " This is the name that will appear under the JB's Run menu. So choose a descriptive name.";_ CHR$(13);_ "4) Select the created item.";CHR$(13);_ "5) Click on the Browse menu, and look for your previously created tkn file on step 1.";_ CHR$(13);_ "6) Just BASIC will tell you should restart the Editor."
case "default"
#main.tb "!contents? searchFor$"
searchFor$=trim$(searchFor$)
if len(searchFor$)>2 then cursor hourglass redim searchList$(500) for i = 1 to 500 ' so so if ar$(i)="" then exit for fileToOpen$= word$(ar$(i),2,chr$(0)) open helpFilePath$; "\"; fileToOpen$ for input as #2 contents$ = input$(#2, lof(#2)) '#main.texteditor contents$ if instr(lower$(contents$), lower$(searchFor$)) then count=count+1 searchList$(count)= ar$(i) end if close #2 next i #main.listbox2 "reload" cursor normal else notice "Please write down more than 2 characters." end if end select end sub
sub lbDoubleClick h$ #h$ "selection? selection$" if selection$ = "" then exit sub
fileToOpen$= word$( selection$,2,chr$(0))
fileToOpen$=replace$( fileToOpen$ , "/", "\" ) run "explorer.exe ";helpFilePath$; "\"; fileToOpen$
end sub
function fileExists(path$, filename$) dim fileExistsInfo$(0,0) files path$, filename$, fileExistsInfo$() fileExists = val(fileExistsInfo$(0, 0)) 'non zero is true end function
function replace$( text$ , this$, tothis$ ) while 1 if instr(text$, this$) then f = instr(text$, this$) lenght=len(this$) text$ = mid$(text$,1,f-1);_ tothis$;mid$(text$,f+lenght) else exit while end if wend replace$=text$ end function
|
|
|
Post by xxgeek on Dec 20, 2020 23:17:06 GMT
Nice addition to JB, thanks for posting this gem. One thing I would like to change is instead of opening in my default browser, I'd like to open the files in a html viewer I use (it's a windows exe) so I only see text. Can I get your program to open the files in my preffered viewer? My peeve is I'd like to stay in the same window while I work, and I'm running JB in wine. When I open an html file with this script it opens my linux default browser (firefox) in a separate window, forcing me to jump back to the JB window after reading the file. I intend to make an exe and have both this script and my html viewer opened in slim windows on each side of the JB window for quick reference. I'm fairly good at hacking around code of all languages and will eventually find what I need, but I'm sure a couple of quick tips would save me a lot of time. Thanks for any and all help in this matter. xxgeek P.S. As my name implies I'm an ex exgeek. Meaning I'm back in business What line/lines in the code needs changed?
|
|
|
Post by Rod on Dec 21, 2020 8:24:50 GMT
In the code you will see “run explorer.exe “ just substitute your .exe name. You will need to add the path if Windows does not know where it exists. So “c:\path\my.exe” leave the rest of the line as it is.
If you get into trouble post the path and file name and the code line as you have coded it.
|
|
|
Post by xxgeek on Dec 21, 2020 18:25:03 GMT
Thanks Rod, I thought that was it but was wondering why explorer would open my firefox browser outside the "wine" environment. I've never like programs opening my browser to go online. I should have got back here to explain my "fix". I just changed my file associations for htm and html files to point to a nice little freeware app named htmlviewer.exe (a stand alone). It looks like it was made for this app. They could be brothers lol. Now when I open JB i have a slim help on one side, and on the other side is the html viewer (slimmed down to fit) for quick reference. When I click a "subject" in this app it instantly shows up in the html viewer, and leaves firefox asleep. If in future this causes me grief I'll change the code here instead. Thanks again Rod. It's good to see people still helping each other in forums. P.S. Even in these days some of us old timers like to go back and do Basic, because it's so easy to understand. Just Basic is far better than the Basic in my old Tandy, and is fast. I'll be promoting Just Basic to all my old friends who, in some cases gave up programming years ago because the other languages were too difficult for them to work in. Since I downloaded JB a month or two ago I have been a new man.
[Edit] -- Holy mackeral, I didn't realize I was writing a book. LOL
|
|
|
Post by davidk64 on Jun 6, 2022 5:53:36 GMT
When I've been struggling to know the right page to click on in the Contents frame of the HTML help I've been resorting to searching the JB "jb2help" folder in Windows Explorer and then trying the various results.
Found this browsing the forum and it's much better - many thanks.
|
|
|
Post by xxgeek on Jul 30, 2022 1:54:19 GMT
Added Tutorial Search Added buttons to open Help and Tutorial Did a little editing too.
'JB v2.0 Help and Tutorial Search 'Created by cundo - Editted by xxgeek - added Tutorial Search
global q$, fileToCheck$, helpFilePath$, resetsearch JBpath$ = "c:\Program Files (x86)\Just Basic v2.0" tutorialPath$ = JBpath$;"\jbtutorial\index.html" openhelp$ = JBpath$;"\jb2help\JustBASIC_2_web\amber_menu.htm" helpFilePath$ = JBpath$;"\jb2help\JustBASIC_2_web" : helpFileMenu$ = "amber_menu.htm"
nomainwin WindowWidth = 700:WindowHeight = 580 UpperLeftX= int((DisplayWidth-WindowWidth)/2) UpperLeftY= int((DisplayHeight-WindowHeight)/2) BackgroundColor$ = "lightgray" ForegroundColor$ = "black"
[resetsearch] if resetsearch = 1 then count = 0 : startAt = 0 : idx = 0 : hrefA = 0 : hrefB = 0 : a = 0 : b = 0 : c = 0 dim helpList$(500), searchList$(500) open helpFilePath$;"\";helpFileMenu$ for input as #1 txt$ = input$(#1, lof(#1)) close #1 lowerTxt$= lower$(txt$) while 1 scan startAt = c+1 a = instr(lowerTxt$, "href",startAt) b = instr(lowerTxt$, ">",a+1) c = instr(lowerTxt$, "</a>",b+1) if a=0 or b=0 or c= 0 then exit while hrefA= instr(lowerTxt$,chr$(34),a+1) hrefB= instr(lowerTxt$,chr$(34),hrefA+1) idx = idx +1 helpList$(idx)= trim$(mid$(txt$,b+1,c-b-1));chr$(0);_ trim$(mid$(txt$,hrefA+1,hrefB-hrefA-1)) wend
if resetsearch = 1 then [reloadSearchLists]
'jbsearch by cundo listbox #main.listbox1, helpList$(, lbDoubleClick, 20, 80, 325, 410 statictext #main.searchtext, "Search For KeyWord(s)", 355, 40, 160, 20 statictext #main.searchheader, "Just Basic v2.0 Help and Tutorial Search", 200, 7, 360, 20 statictext #main.searchin, "Search in >>", 23, 41, 85, 20 statictext #main.clickTip1, "Single Click to Select", 120, 67, 170, 15 statictext #main.clickTip2, "Single Click to Select", 435, 102, 170, 15 statictext #main.or, " or", 210, 38, 20, 20 textbox #main.tb, 510, 35, 155, 25 listbox #main.listbox2, searchList$(, lbDoubleClick, 345, 115, 325, 370 button #main.search, "&Start Searching in JB Help", buttonClick, UL, 400, 70, 220, 25 button #main.contents, "&JB Help File", [helpfiles], UL, 110, 35, 90, 25 button #main.tutorial, "JB Tuto&rial", [tutorial], UL, 245, 35, 90, 25 button #main.tutorial, "Open JB Tutoria&l", [opentutorial], UL, 185, 505, 120, 20
button #main.openhelp, "Open JB Help", [openhelp], UL, 55, 505, 120, 20
open "JBSearch by cundo" for window as #main
#main "trapclose [quit.main]"
#main.listbox1 "singleclickselect" #main.listbox2 "singleclickselect" #main "font arial 10 Bold" #main.listbox1, "font arial 12 bold" #main.listbox2, "font arial 12 bold" #main.clickTip1, "!font arial 8 bold" #main.clickTip2, "!font arial 8 bold" #main.searchin, "!font arial 12 bold" #main.search, "!font arial 12 bold" #main.searchheader, "!font arial 12 bold" '#main.jbforums, "!font arial 8 bold"
'reload search and help lists if selected path changes from Help to Tutorial [reloadSearchLists] 'wait here for input event if resetsearch = 1 then #main.listbox1, "reload" #main.listbox2, "reload" resetsearch = 0 #main.tb, "!setfocus" end if wait
'xxgeek code [tutorial] resetsearch = 1 : helpFilePath$ = JBpath$;"\jbtutorial" helpFileMenu$ = "index.html" : #main.search, "&Start Searching JB Tutorial " : goto [resetsearch]
[helpfiles] resetsearch = 1 : helpFilePath$ = JBpath$;"\jb2help\JustBASIC_2_web" helpFileMenu$ = "amber_menu.htm" #main.search, "&Start Searching in JB Help" goto [resetsearch]
[openhelp] if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";openhelp$ else run "explorer.exe ";openhelp$ end if wait
[opentutorial] if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";tutorialPath$ else run "explorer.exe ";tutorialPath$ end if wait
[forumlink] run "explorer.exe https://justbasiccom.proboards.com/" wait
'quit program, save the current selected List first, and kill all htmlviewer 'windows if User chose to as well [quit.main] close #main end
'the following are cundo's jbsearch code edited by xxgeek 'subroutine to search selection Help, and or Tutorial sub buttonClick h2$ select case word$(h2$,2,".") case "search" #main.tb "!setfocus" #main.tb "!contents? searchFor$" searchFor$=trim$(searchFor$) if len(searchFor$)>2 then cursor hourglass redim searchList$(1000) for i = 1 to 1000 ' so so if helpList$(i)="" then result$ = "yes" #main.tb "!setfocus" : exit for end if fileToOpen$= word$(helpList$(i),2,chr$(0)) print helpFilePath$; " "; fileToOpen$ if fileToOpen$ = "http://www.justbasic.com" then fileToOpen$ = "index.html" open helpFilePath$; "\"; fileToOpen$ for input as #2 contents$ = input$(#2, lof(#2)) if instr(lower$(contents$), lower$(searchFor$)) then count=count+1 searchList$(count)= helpList$(i) end if close #2 next i if count = 0 then prompt "No Entries Found for " + chr$(13) + searchFor$ + " TRY AGAIN?" ; result$ sort searchList$(), 0, count #main.listbox2 "reload" cursor normal else result$ = "yes" prompt " 3 Character Minimum"+chr$(13) +" TRY AGAIN?";result$ end if end select end sub
'subroutine to open selected search item in a browser (htmlviewer if exists\default if not) sub lbDoubleClick h2$ #h2$ "selection? selection$" if selection$ = "" then exit sub fileToOpen$= word$( selection$,2,chr$(0)) if fileToOpen$ = "http://www.justbasic.com" then run "explorer.exe ";fileToOpen$ : wait fileToOpen$=replace$( fileToOpen$ , "/", "\" ) if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then print "fileToOpen$ = ";helpFilePath$;"\";fileToOpen$ 'for testing with mainwin run "htmlviewer.exe ";helpFilePath$;"\";fileToOpen$ else run "explorer.exe ";helpFilePath$;"\";fileToOpen$ end if end sub
function replace$( text$ , this$, tothis$ ) while 1 if instr(text$, this$) then f = instr(text$, this$) lenght=len(this$) text$ = mid$(text$,1,f-1);_ tothis$;mid$(text$,f+lenght) else exit while end if wend replace$=text$ end function
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
|
|